Skip to content

Commit f4401f6

Browse files
committed
Add Navigation
1 parent 494de77 commit f4401f6

5 files changed

+117
-35
lines changed

JavaScriptFlippingAnImage.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,9 @@ Explanation: First reverse each row: [[0,0,1,1],[1,0,0,1],[1,1,1,0],[0,1,0,1]]
3838

3939
### Constraints
4040

41-
```JavaScript
42-
n == image.length
43-
n == image[i].length
44-
1 <= n <= 20
45-
```
46-
41+
- `n == image.length`
42+
- `n == image[i].length`
43+
- `1 <= n <= 20`
4744
- `images[i][j]` is either `0` or `1`.
4845

4946
<br/>
@@ -74,7 +71,7 @@ The function begins by iterating through each row of the image using a `for` loo
7471
Inside the loop, the current row of the image is reversed using the `reverse()` method. This reverses the order of the elements in the row, effectively flipping the image horizontally.
7572
<br/>
7673

77-
Then, the `map()` method is used to iterate through each element in the reversed row. For each element, an arrow function `(x => 1 - x)` is applied. This function subtracts the element from 1, effectively inverting the color. Assuming the elements in the image are either 0 or 1, this operation will switch the value from 0 to 1 or from 1 to 0.
74+
Then, the `map()` method is used to iterate through each element in the reversed row. For each element, an arrow function `(x => 1 - x)` is applied. This function subtracts the element from `1`, effectively inverting the color. Assuming the elements in the image are either `0` or `1`, this operation will switch the value from `0` to `1` or from `1` to `0`.
7875
<br/>
7976

8077
The modified row is then assigned back to the `image[row]` to update the image with the flipped and inverted row.
@@ -85,4 +82,23 @@ After the loop finishes, the modified image is returned as the output of the fun
8582

8683
In summary, this function takes an image as input and performs two operations on each row: it reverses the order of the elements to flip the image horizontally, and it inverts the colors of each pixel. The modified image is then returned as the output of the function.
8784
<br/>
88-
<br/>
85+
<br/>
86+
<br/>
87+
<br/>
88+
89+
### :next_track_button: [Next (Sort Method Overview)][Next]
90+
<br/>
91+
92+
### :previous_track_button: [Previous (Transpose Matrix)][Previous]
93+
<br/>
94+
95+
### :play_or_pause_button: [More Array Challenges][More]
96+
<br/>
97+
98+
### :eject_button: [Return to Course Outline][Return]
99+
<br/>
100+
101+
[Next]: https://github.com/Superklok/JavaScriptSorting/blob/main/JavaScriptArraySortMethodOverview.md
102+
[Previous]: https://github.com/Superklok/JavaScriptArrays/blob/main/JavaScriptTransposeMatrix.md
103+
[More]: https://github.com/Superklok/JavaScriptArrays
104+
[Return]: https://github.com/Superklok/LearnJavaScript

JavaScriptNumberOfIslands.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,9 @@ Output: 3
3636

3737
### Constraints
3838

39-
```JavaScript
40-
m == grid.length
41-
n == grid[i].length
42-
1 <= m, n <= 300
43-
```
44-
39+
- `m == grid.length`
40+
- `n == grid[i].length`
41+
- `1 <= m, n <= 300`
4542
- `grid[i][j]` is `'0'` or `'1'`.
4643

4744
<br/>
@@ -114,4 +111,23 @@ After the DFS traversal is complete, the `numIslands` function returns the final
114111

115112
In summary, I've utilized a depth-first search algorithm to traverse the grid and count the number of islands. The `numIslands` function iterates through each cell, marking visited cells and exploring adjacent cells using the `dfs` function. The `dfs` function recursively explores connected cells until all islands are visited. The final count of islands is returned as the output of the `numIslands` function.
116113
<br/>
117-
<br/>
114+
<br/>
115+
<br/>
116+
<br/>
117+
118+
### :next_track_button: [Next (Sort Array by Parity)][Next]
119+
<br/>
120+
121+
### :previous_track_button: [Previous (Two Sum)][Previous]
122+
<br/>
123+
124+
### :play_or_pause_button: [More Array Challenges][More]
125+
<br/>
126+
127+
### :eject_button: [Return to Course Outline][Return]
128+
<br/>
129+
130+
[Next]: https://github.com/Superklok/JavaScriptArrays/blob/main/JavaScriptSortArrayByParity.md
131+
[Previous]: https://github.com/Superklok/JavaScriptArrays/blob/main/JavaScriptTwoSum.md
132+
[More]: https://github.com/Superklok/JavaScriptArrays
133+
[Return]: https://github.com/Superklok/LearnJavaScript

JavaScriptSortArrayByParity.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ Output: [0]
2828

2929
### Constraints
3030

31-
```JavaScript
32-
1 <= nums.length <= 5000
33-
0 <= nums[i] <= 5000
34-
```
31+
- `1 <= nums.length <= 5000`
32+
- `0 <= nums[i] <= 5000`
3533

3634
<br/>
3735

@@ -76,4 +74,23 @@ Once the loop finishes, the modified array is returned as the output of the func
7674

7775
In summary, this function rearranges the elements of the input array such that all even numbers come before odd numbers, while preserving the relative order of even and odd numbers within their respective groups.
7876
<br/>
79-
<br/>
77+
<br/>
78+
<br/>
79+
<br/>
80+
81+
### :next_track_button: [Next (Transpose Matrix)][Next]
82+
<br/>
83+
84+
### :previous_track_button: [Previous (Number of Islands)][Previous]
85+
<br/>
86+
87+
### :play_or_pause_button: [More Array Challenges][More]
88+
<br/>
89+
90+
### :eject_button: [Return to Course Outline][Return]
91+
<br/>
92+
93+
[Next]: https://github.com/Superklok/JavaScriptArrays/blob/main/JavaScriptTransposeMatrix.md
94+
[Previous]: https://github.com/Superklok/JavaScriptArrays/blob/main/JavaScriptNumberOfIslands.md
95+
[More]: https://github.com/Superklok/JavaScriptArrays
96+
[Return]: https://github.com/Superklok/LearnJavaScript

JavaScriptTransposeMatrix.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ Output: [[1,4],[2,5],[3,6]]
2626

2727
### Constraints
2828

29-
```JavaScript
30-
m == matrix.length
31-
n == matrix[i].length
32-
1 <= m, n <= 1000
33-
1 <= m * n <= 10
34-
-10<= matrix[i][j] <= 10
35-
```
29+
- `m == matrix.length`
30+
- `n == matrix[i].length`
31+
- `1 <= m, n <= 1000`
32+
- `1 <= m * n <= 10⁵`
33+
- `-10⁹ <= matrix[i][j] <= 10⁹`
3634

3735
<br/>
3836

@@ -89,4 +87,23 @@ Finally, the `result` array containing the transposed matrix is returned as the
8987

9088
In summary, this function transposes a given matrix by swapping the rows and columns. It achieves this by iterating over the columns and rows of the input matrix and constructing a new array representing the transposed matrix. The resulting transposed matrix is then returned as the output of the function.
9189
<br/>
92-
<br/>
90+
<br/>
91+
<br/>
92+
<br/>
93+
94+
### :next_track_button: [Next (Flipping an Image)][Next]
95+
<br/>
96+
97+
### :previous_track_button: [Previous (Sort Array by Parity)][Previous]
98+
<br/>
99+
100+
### :play_or_pause_button: [More Array Challenges][More]
101+
<br/>
102+
103+
### :eject_button: [Return to Course Outline][Return]
104+
<br/>
105+
106+
[Next]: https://github.com/Superklok/JavaScriptArrays/blob/main/JavaScriptFlippingAnImage.md
107+
[Previous]: https://github.com/Superklok/JavaScriptArrays/blob/main/JavaScriptSortArrayByParity.md
108+
[More]: https://github.com/Superklok/JavaScriptArrays
109+
[Return]: https://github.com/Superklok/LearnJavaScript

JavaScriptTwoSum.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,9 @@ Output: [0,1]
3636

3737
### Constraints
3838

39-
```JavaScript
40-
2 <= nums.length <= 10
41-
-10<= nums[i] <= 10
42-
-10<= target <= 10
43-
```
44-
39+
- `2 <= nums.length <= 10⁴`
40+
- `-10⁹ <= nums[i] <= 10⁹`
41+
- `-10⁹ <= target <= 10⁹`
4542
- Only one valid answer exists.
4643

4744
<br/>
@@ -94,4 +91,23 @@ After the loop finishes, if no pair of numbers that add up to the target is foun
9491

9592
In summary, this function searches for a pair of numbers in the input array that add up to the target. It uses an object to store previously encountered numbers and their indices. The function iterates through the array, checking if the compliment of each number exists in the object. If a pair is found, their indices are returned. If no pair is found, `[-1, -1]` is returned.
9693
<br/>
97-
<br/>
94+
<br/>
95+
<br/>
96+
<br/>
97+
98+
### :next_track_button: [Next (Number of Islands)][Next]
99+
<br/>
100+
101+
### :previous_track_button: [Previous (Longest Common Prefix)][Previous]
102+
<br/>
103+
104+
### :play_or_pause_button: [More Array Challenges][More]
105+
<br/>
106+
107+
### :eject_button: [Return to Course Outline][Return]
108+
<br/>
109+
110+
[Next]: https://github.com/Superklok/JavaScriptArrays/blob/main/JavaScriptNumberOfIslands.md
111+
[Previous]: https://github.com/Superklok/JavaScriptStrings/blob/main/JavaScriptLongestCommonPrefix.md
112+
[More]: https://github.com/Superklok/JavaScriptArrays
113+
[Return]: https://github.com/Superklok/LearnJavaScript

0 commit comments

Comments
 (0)