Skip to content

chore(deps): bump black from 23.3.0 to 24.3.0 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update README.md
  • Loading branch information
sarvex authored Dec 21, 2023
commit 735681e7c7c9b8eb7ae670f283bcb55101b742c5
40 changes: 40 additions & 0 deletions solution/0000-0099/0054.Spiral Matrix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,46 @@ func spiralOrder(matrix [][]int) (ans []int) {
}
```

### **Rust**

```rust
impl Solution {
pub fn spiral_order(matrix: Vec<Vec<i32>>) -> Vec<i32> {
let mut x1 = 0;
let mut y1 = 0;
let mut x2 = matrix.len() - 1;
let mut y2 = matrix[0].len() - 1;
let mut result = vec![];

while x1 <= x2 && y1 <= y2 {
for j in y1..=y2 {
result.push(matrix[x1][j]);
}
for i in x1 + 1..=x2 {
result.push(matrix[i][y2]);
}
if x1 < x2 && y1 < y2 {
for j in (y1..y2).rev() {
result.push(matrix[x2][j]);
}
for i in (x1 + 1..x2).rev() {
result.push(matrix[i][y1]);
}
}
x1 += 1;
y1 += 1;
if x2 != 0 {
x2 -= 1;
}
if y2 != 0 {
y2 -= 1;
}
}
return result;
}
}
```

### **JavaScript**

```js
Expand Down