— Diary, Programming — 1 min read
Started posting the blogs and discovered a bug. The images stored will be stored according to the name given by the person who posts the image, causing collisions, and that's not what should happen in production. There are two ways to generate a unique ID.
UUID
package which will definitely generate a randomized string. Fixed the unique filename situation, and we are back on track. The only thing left to do is update the blogs and event images. Will be doing it after waking up.
Night night!
Slept a lot and starting the Leetcode Daily Challenge. The question seems to be more of an implementation problem than thee logic itself. I'm making the separate vectors for every diagonal and sorting them individually. After that, I'll put them back into the main matrix.
1vector<vector<int>> diagonalSort(vector<vector<int>> &mat) {2 unordered_map<int, vector<int>> sorted_map;34 for (int i = 0; i < mat.size(); i++) {5 for (int j = 0; j < mat[i].size(); j++) {6 if (sorted_map.find(i - j) == sorted_map.end()) {7 vector<int> temp;8 temp.push_back(mat[i][j]);9 sorted_map[i - j] = temp;10 } else {11 sorted_map[i - j].push_back(mat[i][j]);12 }13 }14 }1516 unordered_map<int, vector<int>>::iterator itr;1718 for (itr = sorted_map.begin(); itr != sorted_map.end(); itr++) {19 sort(itr->second.begin(), itr->second.end());20 }2122 for (int i = 0; i < mat.size(); i++) {23 for (int j = 0; j < mat[i].size(); j++) {24 mat[i][j] = sorted_map[i - j][0];25 sorted_map[i - j].erase(sorted_map[i - j].begin());26 }27 }2829 return mat;30}
Time complexity O(n*m)
where n
and m
are the dimensions of the matrix. And space complexity is O(m+n)
Finally deployed the Raahee website after making the required changes to events and blogs. God, it's been some good 3 months.
Version 2.0 ✅
I guess that was it for today.
Bye!