leetcode

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

commit 0617187c45cd5f62959e7ea8a8c917c0b5457582
parent 312048bc4589038bfd8138227045dd54a73f73a8
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Sun, 10 Dec 2023 17:56:10 +0000

Daily Problem

Diffstat:
AProblems/0867.cpp | 13+++++++++++++
MREADME.md | 1+
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/Problems/0867.cpp b/Problems/0867.cpp @@ -0,0 +1,13 @@ +class Solution { + public: + vector<vector<int>> transpose(const vector<vector<int>> &matrix) const { + const int n = matrix.size(), m = matrix[0].size(); + vector<vector<int>> res(m, vector(n, 0)); + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + res[j][i] = matrix[i][j]; + } + } + return res; + } +}; diff --git a/README.md b/README.md @@ -451,6 +451,7 @@ for solving problems. | 0863 | Medium | [All Nodes Distance K in Binary Tree](Problems/0863.cpp) | | 0864 | Hard | [Shortest Path to Get All Keys](Problems/0864.cpp) | | 0865 | Medium | [Smallest Subtree with all the Deepest Nodes](Problems/0865.cpp) | +| 0867 | Easy | [Transpose Matrix](Problems/0867.cpp) | | 0869 | Medium | [Reordered Power of 2](Problems/0869.cpp) | | 0872 | Easy | [Leaf-Similar Trees](Problems/0872.cpp) | | 0875 | Medium | [Koko Eating Bananas](Problems/0875.cpp) |