Skip to content

Commit 0ed200b

Browse files
committedNov 22, 2023
Time: 189 ms (67.73%), Space: 97.7 MB (46.58%) - LeetHub
1 parent e9c1e98 commit 0ed200b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class Solution {
2+
public:
3+
vector<int> findDiagonalOrder(vector<vector<int>>& nums) {
4+
int size = nums.size();
5+
unordered_map<int, vector<int>> map;
6+
7+
for(int i=0; i<nums.size(); i++) {
8+
for(int j=0; j<nums[i].size(); j++) {
9+
map[i+j].push_back(nums[i][j]);
10+
}
11+
}
12+
13+
vector<int> solution;
14+
15+
for(int i=0; i<map.size(); i++) {
16+
reverse(map[i].begin(), map[i].end());
17+
18+
for(int l : map[i]) {
19+
solution.push_back(l);
20+
}
21+
}
22+
23+
return solution;
24+
}
25+
};

0 commit comments

Comments
 (0)