leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

commit 11378f5654c0d05bd9d97404a6e0e13671ce4758
parent 38ccdc5bc4d31a232612bad96efe63fa9e345e46
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Wed, 22 Nov 2023 21:55:18 +0000

Daily Problem

Diffstat:
AProblems/1424.cpp | 19+++++++++++++++++++
MREADME.md | 1+
2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/Problems/1424.cpp b/Problems/1424.cpp @@ -0,0 +1,19 @@ +class Solution { + typedef tuple<int, int, int> rec_t; + + public: + vector<int> findDiagonalOrder(const vector<vector<int>> &nums) const { + static rec_t arr[100001]; + int n = 0; + for (int i = 0; i < nums.size(); i++) { + for (int j = 0; j < nums[i].size(); j++) { + arr[n++] = {-i - j, i, nums[i][j]}; + } + } + sort(begin(arr), begin(arr) + n, greater<rec_t>()); + vector<int> res; + for (int i = 0; i < n; i++) + res.push_back(get<2>(arr[i])); + return res; + } +}; diff --git a/README.md b/README.md @@ -626,6 +626,7 @@ for solving problems. | 1416 | Hard | [Restore The Array](Problems/1416.cpp) | | 1418 | Medium | [Display Table of Food Orders in a Restaurant](Problems/1418.cpp) | | 1420 | Hard | [Build Array Where You Can Find The Maximum Exactly K Comparisons](Problems/1420.cpp) | +| 1424 | Medium | [Diagonal Traverse II](Problems/1424.cpp) | | 1425 | Hard | [Constrained Subsequence Sum](Problems/1425.cpp) | | 1431 | Easy | [Kids With the Greatest Number of Candies](Problems/1431.cpp) | | 1433 | Medium | [Check If a String Can Break Another String](Problems/1433.cpp) |