Merge branch 'main' into swift

# Conflicts:
#	animation-simulation/数组篇/leetcode219数组中重复元素2.md
#	animation-simulation/数组篇/leetcode59螺旋矩阵2.md
#	animation-simulation/数组篇/leetcode66加一.md
#	animation-simulation/数组篇/leetcode75颜色分类.md
This commit is contained in:
zhenzi
2021-07-17 12:33:02 +08:00
22 changed files with 1404 additions and 476 deletions

View File

@@ -85,6 +85,42 @@ class Solution {
```
C++ Code:
```cpp
class Solution {
public:
vector<int> spiralOrder(vector<vector<int>>& matrix) {
vector <int> arr;
int left = 0, right = matrix[0].size()-1;
int top = 0, down = matrix.size()-1;
while (true) {
for (int i = left; i <= right; ++i) {
arr.emplace_back(matrix[top][i]);
}
top++;
if (top > down) break;
for (int i = top; i <= down; ++i) {
arr.emplace_back(matrix[i][right]);
}
right--;
if (left > right) break;
for (int i = right; i >= left; --i) {
arr.emplace_back(matrix[down][i]);
}
down--;
if (top > down) break;
for (int i = down; i >= top; --i) {
arr.emplace_back(matrix[i][left]);
}
left++;
if (left > right) break;
}
return arr;
}
};
```
Python3 Code:
```python