Skip to content

Commit a27a326

Browse files
Fix pre-commit hook: use git add data/ instead of glob pattern
1 parent efe6efd commit a27a326

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
npm run format:json
2-
git add 'data/**/*.json'
2+
git add data/

explanations/3179/en.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
**1.1 Constraints & Complexity:**
88

99
- **Input Size:** n and k are both between 1 and 1000. The values can grow very large, so we need modulo 10^9 + 7.
10-
- **Time Complexity:** O(n * k) - we iterate k times, and for each iteration, we process n-1 elements.
10+
- **Time Complexity:** O(n \* k) - we iterate k times, and for each iteration, we process n-1 elements.
1111
- **Space Complexity:** O(n) - we maintain an array of size n.
1212
- **Edge Case:** When k=0, the array remains [1,1,...,1], so the result is 1.
1313

@@ -17,7 +17,7 @@ The goal is to apply prefix sum operation k times. Each second, we compute the p
1717

1818
**1.3 Brute force vs. optimized strategy:**
1919

20-
- **Brute Force:** Simulate k seconds by computing prefix sums k times. This is O(n * k) time and O(n) space.
20+
- **Brute Force:** Simulate k seconds by computing prefix sums k times. This is O(n \* k) time and O(n) space.
2121
- **Optimized Strategy:** The same approach is already optimal. We can't avoid computing each prefix sum operation.
2222
- **Optimization:** Using modulo arithmetic ensures we don't overflow, and the direct simulation is the most straightforward approach.
2323

@@ -42,14 +42,14 @@ We apply prefix sum k=5 times.
4242

4343
**2.3 Trace Walkthrough:**
4444

45-
| Second | Array State | Action |
46-
|--------|-------------|--------|
47-
| 0 | [1, 1, 1, 1] | Initial state |
48-
| 1 | [1, 2, 3, 4] | Prefix sum: arr[1]=1+1=2, arr[2]=1+2=3, arr[3]=1+2+3=4 |
49-
| 2 | [1, 3, 6, 10] | Prefix sum: arr[1]=1+2=3, arr[2]=1+3+2=6, arr[3]=1+3+6=10 |
50-
| 3 | [1, 4, 10, 20] | Prefix sum: arr[1]=1+3=4, arr[2]=1+4+3=10, arr[3]=1+4+10=20 |
51-
| 4 | [1, 5, 15, 35] | Prefix sum: arr[1]=1+4=5, arr[2]=1+5+4=15, arr[3]=1+5+15=35 |
52-
| 5 | [1, 6, 21, 56] | Prefix sum: arr[1]=1+5=6, arr[2]=1+6+5=21, arr[3]=1+6+21=56 |
45+
| Second | Array State | Action |
46+
| ------ | -------------- | ----------------------------------------------------------- |
47+
| 0 | [1, 1, 1, 1] | Initial state |
48+
| 1 | [1, 2, 3, 4] | Prefix sum: arr[1]=1+1=2, arr[2]=1+2=3, arr[3]=1+2+3=4 |
49+
| 2 | [1, 3, 6, 10] | Prefix sum: arr[1]=1+2=3, arr[2]=1+3+2=6, arr[3]=1+3+6=10 |
50+
| 3 | [1, 4, 10, 20] | Prefix sum: arr[1]=1+3=4, arr[2]=1+4+3=10, arr[3]=1+4+10=20 |
51+
| 4 | [1, 5, 15, 35] | Prefix sum: arr[1]=1+4=5, arr[2]=1+5+4=15, arr[3]=1+5+15=35 |
52+
| 5 | [1, 6, 21, 56] | Prefix sum: arr[1]=1+5=6, arr[2]=1+6+5=21, arr[3]=1+6+21=56 |
5353

5454
**2.4 Increment and Loop:**
5555

@@ -58,4 +58,3 @@ After k iterations, we have the final array state.
5858
**2.5 Return Result:**
5959

6060
The value at index n-1 (index 3) after k=5 seconds is 56, which matches the example output.
61-

0 commit comments

Comments
 (0)