Skip to content

Commit b1a8c1b

Browse files
committed
fix cheatsheet Liquid templating error for Jekyll deploy
1 parent ad6ddfd commit b1a8c1b

File tree

8 files changed

+59
-27
lines changed

8 files changed

+59
-27
lines changed

doc/cheatsheet/backtrack.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ These are often **permutation problems**, where:
100100
- You **should revisit** earlier choices (sometimes)
101101

102102

103-
-> Dont use `start_idx` when:
103+
-> Don't use `start_idx` when:
104104
- You're generating **permutations**
105105
- You need **all orderings**
106106
- Choices are not sequential (e.g., trying all positions)
@@ -789,10 +789,10 @@ if (i > 0 && nums[i] == nums[i - 1] && !used[i - 1])
789789

790790
// dfsFind(board, word, x+1, y, visited, start_idx + 1)
791791

792-
// 1) Youre passing a copy of start_idx + 1 to the recursive function. So, inside the recursive call, start_idx is a new variable, and changes to it wont affect the start_idx in the calling function.
792+
// 1) You're passing a copy of start_idx + 1 to the recursive function. So, inside the recursive call, start_idx is a new variable, and changes to it won't affect the start_idx in the calling function.
793793

794794

795-
// 2) We dont need start_idx -= 1; because start_idx is passed by value, not by reference. So modifying it in the recursive call doesnt affect the callers start_idx. Were already handling the correct index in each recursive call by passing start_idx + 1.
795+
// 2) We don't need start_idx -= 1; because start_idx is passed by value, not by reference. So modifying it in the recursive call doesn't affect the caller's start_idx. We're already handling the correct index in each recursive call by passing start_idx + 1.
796796

797797
```
798798

@@ -1092,7 +1092,7 @@ private boolean dfs_(char[][] board, int y, int x, int idx, String word, boolean
10921092
/** NOTE !!! we update visited on x, y here */
10931093
visited[y][x] = true;
10941094

1095-
int[][] dirs = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
1095+
int[][] dirs = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };
10961096
/**
10971097
* NOTE !!!
10981098
*
@@ -1198,13 +1198,13 @@ class Solution(object):
11981198
// V0'
11991199
// IDEA : Backtracking
12001200
// https://leetcode.com/problems/subsets/editorial/
1201-
List<List<Integer>> output = new ArrayList();
1201+
List<List<Integer>> output = new ArrayList<>();
12021202
int n, k;
12031203

12041204
public void backtrack(int first, ArrayList<Integer> curr, int[] nums) {
12051205
// if the combination is done
12061206
if (curr.size() == k) {
1207-
output.add(new ArrayList(curr));
1207+
output.add(new ArrayList<>(curr));
12081208
return;
12091209
}
12101210
/** NOTE HERE !!!
@@ -1701,9 +1701,9 @@ private void backtrack(String s, int start, List<String> currentList) {
17011701
*
17021702
* • This is the base case of the recursion.
17031703
*
1704-
* • It means: If weve reached the end of the string,
1704+
* • It means: "If we've reached the end of the string,
17051705
* then the current list of substrings (currentList)
1706-
* forms a valid full partition of s into palindromes.
1706+
* forms a valid full partition of s into palindromes."
17071707
*
17081708
* • -> So we add a copy of currentList into
17091709
* the final result list partitionRes.
@@ -1712,9 +1712,9 @@ private void backtrack(String s, int start, List<String> currentList) {
17121712
* - Why start == s.length()?
17131713
*
17141714
* • Because start is the index from which
1715-
* were currently trying to partition.
1715+
* we're currently trying to partition.
17161716
*
1717-
* • If start == s.length(), it means weve
1717+
* • If start == s.length(), it means we've
17181718
* used up all characters in s, and currentList is now a full,
17191719
* valid partition.
17201720
*/
@@ -2039,5 +2039,4 @@ private boolean dfs(int crs, Map<Integer, List<Integer>> preMap, Set<Integer> vi
20392039
visiting.remove(crs);
20402040
preMap.get(crs).clear(); // Clear prerequisites as the course is confirmed to be processed
20412041
return true;
2042-
}
2043-
```
2042+
}

doc/cheatsheet/bfs.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ class Solution:
437437
for x, y in q:
438438
# get the distance from a gate
439439
distance = rooms[x][y]+1
440-
directions = [(-1,0), (1,0), (0,-1), (0,1)]
441-
for dx, dy in directions:
440+
dirs = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} }
441+
for dx, dy in dirs:
442442
# find the INF around the gate
443443
new_x, new_y = x+dx, y+dy
444444
if 0 <= new_x < row and 0 <= new_y < col and rooms[new_x][new_y] == 2147483647:
@@ -484,7 +484,7 @@ class Solution:
484484

485485
int space_cnt = 0;
486486
int gete_cnt = 0;
487-
int[][] dirs = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
487+
int[][] dirs = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };
488488

489489
int len = rooms.length;
490490
int width = rooms[0].length;
@@ -1033,7 +1033,7 @@ public int[][] updateMatrix_0_1(int[][] mat) {
10331033
*
10341034
* * You perform a **BFS for every 1** in the matrix.
10351035
* * In worst case, you scan the whole matrix **once per 1**.
1036-
* * Thats **O(N × M × (N + M))** — very slow for large inputs.
1036+
* * That's **O(N × M × (N + M))** — very slow for large inputs.
10371037
*
10381038
* ---
10391039
*
@@ -1043,7 +1043,7 @@ public int[][] updateMatrix_0_1(int[][] mat) {
10431043
*
10441044
* #### Why this works:
10451045
*
1046-
* * You flip the problem: instead of asking *how far is this 1 from a 0?*, you ask *how far can each 0 reach a 1?*
1046+
* * You flip the problem: instead of asking *"how far is this 1 from a 0?"*, you ask *"how far can each 0 reach a 1?"*
10471047
* * When you expand from all 0s **at the same time**, you ensure that **each 1 gets the shortest path to a 0**, because BFS guarantees minimum-distance traversal.
10481048
* * Time complexity is **O(N × M)** — each cell is visited only once.
10491049
*
@@ -1057,7 +1057,7 @@ public int[][] updateMatrix_0_1(int[][] mat) {
10571057
}
10581058
}
10591059

1060-
int[][] dirs = { { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 0 } };
1060+
int[][] dirs = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };
10611061

10621062
// 2️⃣ BFS from all 0s
10631063
while (!queue.isEmpty()) {

doc/cheatsheet/dfs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ _is_island(grid, x, y-1, seen);
284284
// V2
285285
// private boolean _is_island_2(char[][] grid, int x, int y, boolean[][] seen) {}
286286

287-
int[][] directions = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
287+
int[][] directions = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };
288288

289289
for (int[] dir : directions) {
290290
int newX = x + dir[0];
@@ -1771,7 +1771,7 @@ private void reveal_1(char[][] board, int x, int y) {
17711771
* and avoid unnecessary recursion.
17721772
*
17731773
* - 3) board[x][y] != 'E'
1774-
* • Avoids re-processing non-‘E cells
1774+
* • Avoids re-processing non-‘E' cells
17751775
* • The board can have:
17761776
* • 'M' → Mine (already handled separately)
17771777
* • 'X' → Clicked mine (game over case)
@@ -1795,7 +1795,7 @@ private void reveal_1(char[][] board, int x, int y) {
17951795
* • Counts 1 mine nearby → Updates board[0][0] = '1'
17961796
* • Does NOT recurse further, avoiding unnecessary work.
17971797
*
1798-
* What If We Didnt Check board[x][y] != 'E'?
1798+
* What If We Didn't Check board[x][y] != 'E'?
17991799
* • It might try to expand into already processed cells, leading to redundant computations or infinite recursion.
18001800
*
18011801
*/

doc/cheatsheet/java_trick.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ public List<List<Integer>> levelOrder(TreeNode root) {
325325
*
326326
* • res is a List<List<Integer>>, where each inner list represents a level of the tree.
327327
* • res.get(depth) retrieves the list at the given depth.
328-
* • .add(curRoot.val) adds the current nodes value to the corresponding depth level.
328+
* • .add(curRoot.val) adds the current node's value to the corresponding depth level.
329329
*
330330
*/
331331

@@ -1254,7 +1254,7 @@ return true;
12541254
```java
12551255
// java
12561256
// LC 417
1257-
public int[][] DIRECTIONS = new int[][]{{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
1257+
public int[][] DIRECTIONS = new int[][]{ {0, 1}, {1, 0}, {-1, 0}, {0, -1} };
12581258
```
12591259

12601260
### 1-18) Arrays.fill (1 D)
@@ -1640,7 +1640,7 @@ orderMap[order.charAt(i) - 'a'] = i;
16401640

16411641
### 🔍 What's happening?
16421642

1643-
Lets say:
1643+
Let's say:
16441644
```java
16451645
order = "hlabcdefgijkmnopqrstuvwxyz";
16461646
```

doc/cheatsheet/matrix.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,15 +466,15 @@ class Solution(object):
466466
* -> so we have 3 layer loop as below:
467467
* - i : Iterates over the rows of A (outer loop).
468468
* - j : Iterates over the columns of B (second loop).
469-
* - k : Iterates over the shared dimension (columns of A or rows of B ) to compute the dot product (inner loop).
469+
* - k : Iterates over the "shared dimension" (columns of A or rows of B ) to compute the dot product (inner loop).
470470
*
471471
*
472472
* ->
473473
*
474474
* The Role of the Loops
475475
* 1. Outer loop ( i ): Iterates over the rows of mat1 to calculate each row of the result matrix.
476476
* 2. Middle loop ( j ): Iterates over the columns of mat2 to compute each element in a row of the result matrix.
477-
* 3. Inner loop ( k ): Iterates over the shared dimension to compute the dot product of the i^{th} row of mat1 and the j^{th} column of mat2.
477+
* 3. Inner loop ( k ): Iterates over the "shared dimension" to compute the dot product of the i^{th} row of mat1 and the j^{th} column of mat2.
478478
*
479479
*
480480
* -> Why the Inner Loop ( k ) Exists ?
@@ -488,7 +488,7 @@ class Solution(object):
488488
public static int[][] multiply(int[][] mat1, int[][] mat2) {
489489
// Edge case: Single element matrices
490490
if (mat1.length == 1 && mat1[0].length == 1 && mat2.length == 1 && mat2[0].length == 1) {
491-
return new int[][]{{mat1[0][0] * mat2[0][0]}};
491+
return new int[][]{ {mat1[0][0] * mat2[0][0]} };
492492
}
493493

494494
int l_1 = mat1.length; // Number of rows in mat1

ref_code/CtCI-6th-Edition-master/.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,15 @@
1414
<natures>
1515
<nature>org.eclipse.jdt.core.javanature</nature>
1616
</natures>
17+
<filteredResources>
18+
<filter>
19+
<id>1751452257593</id>
20+
<name></name>
21+
<type>30</type>
22+
<matcher>
23+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
24+
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
25+
</matcher>
26+
</filter>
27+
</filteredResources>
1728
</projectDescription>

ref_code/crack_code/Cracking-the-Coding-Interview_solutions-master/.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,15 @@
1414
<natures>
1515
<nature>org.eclipse.jdt.core.javanature</nature>
1616
</natures>
17+
<filteredResources>
18+
<filter>
19+
<id>1751452257582</id>
20+
<name></name>
21+
<type>30</type>
22+
<matcher>
23+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
24+
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
25+
</matcher>
26+
</filter>
27+
</filteredResources>
1728
</projectDescription>

ref_code/crack_code/CtCI-6th-Edition-master/.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,15 @@
1414
<natures>
1515
<nature>org.eclipse.jdt.core.javanature</nature>
1616
</natures>
17+
<filteredResources>
18+
<filter>
19+
<id>1751452257597</id>
20+
<name></name>
21+
<type>30</type>
22+
<matcher>
23+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
24+
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
25+
</matcher>
26+
</filter>
27+
</filteredResources>
1728
</projectDescription>

0 commit comments

Comments
 (0)