Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 23 additions & 0 deletions solution/0600-0699/0657.Robot Return to Origin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,29 @@ function judgeCircle(moves: string): boolean {
}
```

#### Rust

```rust
impl Solution {
pub fn judge_circle(moves: String) -> bool {
let mut x: i32 = 0;
let mut y: i32 = 0;

for c in moves.chars() {
match c {
'U' => y += 1,
'D' => y -= 1,
'L' => x -= 1,
'R' => x += 1,
_ => {}
}
}

x == 0 && y == 0
}
}
```

#### JavaScript

```js
Expand Down
23 changes: 23 additions & 0 deletions solution/0600-0699/0657.Robot Return to Origin/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,29 @@ function judgeCircle(moves: string): boolean {
}
```

#### Rust

```rust
impl Solution {
pub fn judge_circle(moves: String) -> bool {
let mut x: i32 = 0;
let mut y: i32 = 0;

for c in moves.chars() {
match c {
'U' => y += 1,
'D' => y -= 1,
'L' => x -= 1,
'R' => x += 1,
_ => {}
}
}

x == 0 && y == 0
}
}
```

#### JavaScript

```js
Expand Down
18 changes: 18 additions & 0 deletions solution/0600-0699/0657.Robot Return to Origin/Solution.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
impl Solution {
pub fn judge_circle(moves: String) -> bool {
let mut x: i32 = 0;
let mut y: i32 = 0;

for c in moves.chars() {
match c {
'U' => y += 1,
'D' => y -= 1,
'L' => x -= 1,
'R' => x += 1,
_ => {}
}
}

x == 0 && y == 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function minCost(
startPos: number[],
homePos: number[],
rowCosts: number[],
colCosts: number[]
colCosts: number[],
): number {
const calc = (nums: number[], i: number, j: number): number => {
let res = 0;
Expand All @@ -15,13 +15,9 @@ function minCost(
const [x0, y0] = startPos;
const [x1, y1] = homePos;

const dx = x0 < x1
? calc(rowCosts, x0 + 1, x1)
: calc(rowCosts, x1, x0 - 1);
const dx = x0 < x1 ? calc(rowCosts, x0 + 1, x1) : calc(rowCosts, x1, x0 - 1);

const dy = y0 < y1
? calc(colCosts, y0 + 1, y1)
: calc(colCosts, y1, y0 - 1);
const dy = y0 < y1 ? calc(colCosts, y0 + 1, y1) : calc(colCosts, y1, y0 - 1);

return dx + dy;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 简单
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3880.Minimum%20Absolute%20Difference%20Between%20Two%20Values/README.md
rating: 1257
source: 第 179 场双周赛 Q1
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Easy
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3880.Minimum%20Absolute%20Difference%20Between%20Two%20Values/README_EN.md
rating: 1257
source: Biweekly Contest 179 Q1
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3881.Direction%20Assignments%20with%20Exactly%20K%20Visible%20People/README.md
rating: 1760
source: 第 179 场双周赛 Q2
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3881.Direction%20Assignments%20with%20Exactly%20K%20Visible%20People/README_EN.md
rating: 1760
source: Biweekly Contest 179 Q2
---

<!-- problem:start -->
Expand Down
2 changes: 2 additions & 0 deletions solution/3800-3899/3882.Minimum XOR Path in a Grid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3882.Minimum%20XOR%20Path%20in%20a%20Grid/README.md
rating: 1770
source: 第 179 场双周赛 Q3
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3882.Minimum%20XOR%20Path%20in%20a%20Grid/README_EN.md
rating: 1770
source: Biweekly Contest 179 Q3
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3883.Count%20Non%20Decreasing%20Arrays%20With%20Given%20Digit%20Sums/README.md
rating: 2172
source: 第 179 场双周赛 Q4
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3883.Count%20Non%20Decreasing%20Arrays%20With%20Given%20Digit%20Sums/README_EN.md
rating: 2172
source: Biweekly Contest 179 Q4
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 简单
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3884.First%20Matching%20Character%20From%20Both%20Ends/README.md
rating: 1161
source: 第 495 场周赛 Q1
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Easy
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3884.First%20Matching%20Character%20From%20Both%20Ends/README_EN.md
rating: 1161
source: Weekly Contest 495 Q1
---

<!-- problem:start -->
Expand Down
2 changes: 2 additions & 0 deletions solution/3800-3899/3885.Design Event Manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3885.Design%20Event%20Manager/README.md
rating: 1548
source: 第 495 场周赛 Q2
---

<!-- problem:start -->
Expand Down
2 changes: 2 additions & 0 deletions solution/3800-3899/3885.Design Event Manager/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3885.Design%20Event%20Manager/README_EN.md
rating: 1548
source: Weekly Contest 495 Q2
---

<!-- problem:start -->
Expand Down
2 changes: 2 additions & 0 deletions solution/3800-3899/3886.Sum of Sortable Integers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3886.Sum%20of%20Sortable%20Integers/README.md
rating: 1999
source: 第 495 场周赛 Q3
---

<!-- problem:start -->
Expand Down
2 changes: 2 additions & 0 deletions solution/3800-3899/3886.Sum of Sortable Integers/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3886.Sum%20of%20Sortable%20Integers/README_EN.md
rating: 1999
source: Weekly Contest 495 Q3
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3887.Incremental%20Even-Weighted%20Cycle%20Queries/README.md
rating: 2128
source: 第 495 场周赛 Q4
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3887.Incremental%20Even-Weighted%20Cycle%20Queries/README_EN.md
rating: 2128
source: Weekly Contest 495 Q4
---

<!-- problem:start -->
Expand Down
Loading
Loading