Skip to content

Commit 4ab66d1

Browse files
Update formatting in explanations and fix solution 3643
1 parent 0f77f7f commit 4ab66d1

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

explanations/3643/en.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ We iterate i from 0 to k//2 - 1 (i.e., 0 to 0 for k=3).
4242

4343
**2.3 Trace Walkthrough:**
4444

45-
| i | top | bottom | Before Swap | After Swap |
46-
|---|-----|--------|-------------|------------|
47-
| 0 | 1 | 3 | grid[1][0:3] = [5,6,7]<br>grid[3][0:3] = [13,14,15] | grid[1][0:3] = [13,14,15]<br>grid[3][0:3] = [5,6,7] |
45+
| i | top | bottom | Before Swap | After Swap |
46+
| --- | --- | ------ | --------------------------------------------------- | --------------------------------------------------- |
47+
| 0 | 1 | 3 | grid[1][0:3] = [5,6,7]<br>grid[3][0:3] = [13,14,15] | grid[1][0:3] = [13,14,15]<br>grid[3][0:3] = [5,6,7] |
4848

4949
**2.4 Increment and Loop:**
5050

@@ -53,4 +53,3 @@ After swapping, the grid becomes: `[[1,2,3,4],[13,14,15,8],[9,10,11,12],[5,6,7,1
5353
**2.5 Return Result:**
5454

5555
The result is the grid with the submatrix flipped vertically: `[[1,2,3,4],[13,14,15,8],[9,10,11,12],[5,6,7,16]]`
56-

explanations/3698/en.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ We expand both pointers while maintaining strict increase/decrease.
4343

4444
**2.3 Trace Walkthrough:**
4545

46-
| Step | Action | l | r | lsum | rsum | nums[l] | nums[r] |
47-
|------|--------|---|---|------|------|---------|---------|
48-
| 1 | Expand left (1<3) | 0→1 | 2 | 1 | 0 | 3 | 2 |
49-
| 2 | Expand right (3>2) | 1 | 2→1 | 1 | 2 | 3 | 3 |
50-
| 3 | Pointers meet | 1 | 1 | 1 | 2 | 3 | 3 |
46+
| Step | Action | l | r | lsum | rsum | nums[l] | nums[r] |
47+
| ---- | ------------------ | --- | --- | ---- | ---- | ------- | ------- |
48+
| 1 | Expand left (1<3) | 0→1 | 2 | 1 | 0 | 3 | 2 |
49+
| 2 | Expand right (3>2) | 1 | 2→1 | 1 | 2 | 3 | 3 |
50+
| 3 | Pointers meet | 1 | 1 | 1 | 2 | 3 | 3 |
5151

5252
Since l==r, we have a single peak. Try both options:
53+
5354
- Option 1: lsum + nums[l] = 1+3=4, rsum=2, diff=|4-2|=2
5455
- Option 2: lsum=1, rsum + nums[r]=2+3=5, diff=|1-5|=4
5556
- Minimum: 2
@@ -61,4 +62,3 @@ The algorithm handles all cases: single peak, flat peak, or invalid.
6162
**2.5 Return Result:**
6263

6364
The result is 2, the minimum absolute difference.
64-

solutions/3643/01.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
class Solution:
2-
def reverseSubmatrix(self, grid: List[List[int]], x: int, y: int, k: int) -> List[List[int]]:
2+
def reverseSubmatrix(
3+
self, grid: List[List[int]], x: int, y: int, k: int
4+
) -> List[List[int]]:
35
# Swap corresponding rows within the k×k block
46
for i in range(k // 2):
57
top = x + i
68
bottom = x + k - 1 - i
7-
grid[top][y:y + k], grid[bottom][y:y + k] = (
8-
grid[bottom][y:y + k],
9-
grid[top][y:y + k],
9+
grid[top][y : y + k], grid[bottom][y : y + k] = (
10+
grid[bottom][y : y + k],
11+
grid[top][y : y + k],
1012
)
1113
return grid
12-

0 commit comments

Comments
 (0)