2022-07-19 解題區►Leetcode►Easy Leetcode 566 - Reshape the Matrix 題目 Problem# 把 mxn 的 matrix 轉成 rxc 的 matrix 想法# 照著實作即可 時間複雜度: $\mathcal{O}(n^2)$ 空間複雜度: $\mathcal{O}(n^2)$ AC Code# 賞析# 12// init 2d vector -> arr[r][c] vector<vector<int>> arr(r, vector<int>(c)); https://leetcode.com/problems/reshape-the-matrix/discuss/1317151/C%2B%2B-One-Loop-Easy-Solution-or-Column-first-and-Row-first-Approaches 用 i / r, i % r 算出 index Newer Leetcode 118 - Pascal's Triangle Older Leetcode 217 - Contains Duplicate