Skip to content

chore(deps): bump semver from 6.3.0 to 6.3.1 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from
Closed
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
40,380 changes: 20,243 additions & 20,137 deletions images/starcharts.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 20 additions & 1 deletion lcci/16.17.Contiguous Sequence/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,29 @@ var maxSubArray = function (nums) {
};
```

### **...**
### **PHP**

```php
class Solution {
/**
* @param Integer[] $nums
* @return Integer
*/
function maxSubArray($nums) {
$pre = 0;
$max = $nums[0];
for ($i = 0; $i < count($nums); $i++) {
$pre = max($pre + $nums[$i], $nums[$i]);
$max = max($pre, $max);
}
return $max;
}
}
```

### **...**

```

```

Expand Down
21 changes: 20 additions & 1 deletion lcci/16.17.Contiguous Sequence/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,29 @@ var maxSubArray = function (nums) {
};
```

### **...**
### **PHP**

```php
class Solution {
/**
* @param Integer[] $nums
* @return Integer
*/
function maxSubArray($nums) {
$pre = 0;
$max = $nums[0];
for ($i = 0; $i < count($nums); $i++) {
$pre = max($pre + $nums[$i], $nums[$i]);
$max = max($pre, $max);
}
return $max;
}
}
```

### **...**

```

```

Expand Down
15 changes: 15 additions & 0 deletions lcci/16.17.Contiguous Sequence/Solution.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution {
/**
* @param Integer[] $nums
* @return Integer
*/
function maxSubArray($nums) {
$pre = 0;
$max = $nums[0];
for ($i = 0; $i < count($nums); $i++) {
$pre = max($pre + $nums[$i], $nums[$i]);
$max = max($pre, $max);
}
return $max;
}
}
Binary file modified lcp/LCP 70. 沙地治理/images/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lcp/LCP 70. 沙地治理/images/demo2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lcp/LCP 75. 传送卷轴/images/1681714676-gksEMT-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lcp/LCP 75. 传送卷轴/images/1681714693-LsxKAh-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lcp/LCP 75. 传送卷轴/images/1681789509-wTekFu-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lcp/LCP 75. 传送卷轴/images/1681800985-KrSdru-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lcp/LCP 76. 魔法棋盘/images/1681714583-unbRox-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lcp/LCP 76. 魔法棋盘/images/1681714596-beaOHK-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion solution/0000-0099/0001.Two Sum/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

## Solutions

**Approach 1: Hash Table**
**Solution 1: Hash Table**

We can use the hash table $m$ to store the array value and the corresponding subscript.

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0002.Add Two Numbers/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

## Solutions

**Approach 1: Simulation**
**Solution 1: Simulation**

We traverse two linked lists $l_1$ and $l_2$ at the same time, and use the variable $carry$ to indicate whether there is a carry.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Notice that the answer must be a substring, &quot;pwke&quot; is a subsequence an

## Solutions

**Approach 1: Two pointers + Hash Table**
**Solution 1: Two pointers + Hash Table**

Define a hash table to record the characters in the current window. Let $i$ and $j$ represent the start and end positions of the non-repeating substring, respectively. The length of the longest non-repeating substring is recorded by `ans`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

## Solutions

**Approach 1: Dynamic Programming**
**Solution 1: Dynamic Programming**

Set $dp[i][j]$ to indicate whether the string $s[i..j]$ is a palindrome.

Expand All @@ -41,7 +41,7 @@ Set $dp[i][j]$ to indicate whether the string $s[i..j]$ is a palindrome.

The time complexity is $O(n^2)$ and the space complexity is $O(n^2)$. Where $n$ is the length of the string $s$.

**Approach 2: Enumerate the Palindrome Center**
**Solution 2: Enumerate the Palindrome Center**

We can enumerate the palindrome center, spread to both sides, and find the longest palindrome.

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0006.Zigzag Conversion/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ P I

## Solutions

**Approach 1: Simulation**
**Solution 1: Simulation**

We use a 2D array $g$ to simulate the process of the $Z$-shaped arrangement, where $g[i][j]$ represents the character in the $i$th row and the $j$th column. Initially, $i=0$, and we also define a direction variable $k$, initially $k=-1$, which means up.

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0007.Reverse Integer/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

## Solutions

**Approach 1: Mathematical**
**Solution 1: Mathematical**

Let $mi$ and $mx$ be $-2^{31}$ and $2^{31} - 1$ respectively. The reversed result $ans$ needs to satisfy $mi \le ans \le mx$.

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0012.Integer to Roman/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ M 1000</pre>

## Solutions

**Approach 1: Greedy**
**Solution 1: Greedy**

We can list all possible symbols $cs$ and corresponding values $vs$ first, then enumerate the value $vs[i]$ from large to small, and use the symbol $cs[i]$ as much as possible each time until the number $num$ becomes $0$.

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0013.Roman to Integer/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ M 1000</pre>

## Solutions

**Approach 1: Hash table + simulation**
**Solution 1: Hash table + simulation**

We first use a hash table $d$ to record the numerical value corresponding to each character, and then traverse the string $s$ from left to right. If the numerical value corresponding to the current character is less than the numerical value corresponding to the right character, subtract the numerical value corresponding to the current character, otherwise add the numerical value corresponding to the current character.

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0014.Longest Common Prefix/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

## Solutions

**Approach 1: Character Comparison**
**Solution 1: Character Comparison**

We take the first string $strs[0]$ as the benchmark, and compare the $i$th character of the string after it with the $i$th character of $strs[0]$. If it is the same, continue to compare the next character, otherwise return the first $i$ characters of $strs[0]$.

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0015.3Sum/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Notice that the order of the output and the order of the triplets does not matte

## Solutions

**Approach 1: Sort + Two Pointers**
**Solution 1: Sort + Two Pointers**

We notice that the problem does not require us to return the triplet in order, so we might as well sort the array first, which makes it easy to skip duplicate elements.

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0018.4Sum/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

## Solutions

**Approach 1: Two Pointers**
**Solution 1: Two Pointers**

Time complexity $O(n^3)$, Space complexity $O(\log n)$.

Expand Down
4 changes: 2 additions & 2 deletions solution/0000-0099/0024.Swap Nodes in Pairs/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@

## Solutions

**Approach 1: Iteration**
**Solution 1: Iteration**

Time complexity $O(n)$, Space complexity $O(1)$.

**Approach 2: Recursion**
**Solution 2: Recursion**

Time complexity $O(n)$, Space complexity $O(n)$.

Expand Down
4 changes: 2 additions & 2 deletions solution/0000-0099/0025.Reverse Nodes in k-Group/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@

## Solutions

**Approach 1: Iteration**
**Solution 1: Iteration**

Time complexity $O(n)$, Space complexity $O(1)$.

**Approach 2: Recursion**
**Solution 2: Recursion**

Time complexity $O(n)$, Space complexity $O(\log _k n)$.

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0027.Remove Element/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ It does not matter what you leave beyond the returned k (hence they are undersco

## Solutions

**Approach 1: One Pass**
**Solution 1: One Pass**

We use the variable $k$ to record the number of elements that are not equal to $val$.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ The first occurrence is at index 0, so we return 0.

## Solutions

**Approach 1: Traverse**
**Solution 1: Traverse**

Time complexity $O((n-m) \times m)$, Space complexity $O(1)$.

**Approach 2: Rabin-Karp**
**Solution 2: Rabin-Karp**

Time complexity $O(n+m)$, Space complexity $O(1)$.

**Approach 3: KMP**
**Solution 3: KMP**

Time complexity $O(n+m)$, Space complexity $O(m)$.

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0029.Divide Two Integers/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

## Solutions

**Approach 1: Quick Power**
**Solution 1: Quick Power**

Time complexity $O(\log a \times \log b)$, Space complexity $O(1)$.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The substring starting at 12 is &quot;thefoobar&quot;. It is the concatenation o

## Solutions

**Approach 1: Hash Table + Sliding Window**
**Solution 1: Hash Table + Sliding Window**

We use a hash table $cnt$ to count the number of times each word in $words$ appears, and use a hash table $cnt1$ to count the number of times each word in the current sliding window appears. Let the length of the string $s$ be $m$, the number of words in the string array $words$ be $n$, and the length of each word be $k$.

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0031.Next Permutation/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

## Solutions

**Approach 1: Two traversals**
**Solution 1: Two traversals**

We first traverse the array from back to front and find the first position $i$ where $nums[i] \lt nums[i + 1]$.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

## Solutions

**Approach 1: Dynamic Programming**
**Solution 1: Dynamic Programming**

We define $f[i]$ to be the length of the longest valid parentheses that ends with $s[i-1]$, and the answer is $max(f[i])$.

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0036.Valid Sudoku/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

## Solutions

**Approach 1: Traversal once**
**Solution 1: Traversal once**

The valid sudoku satisfies the following three conditions:

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0042.Trapping Rain Water/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

## Solutions

**Approach 1: Dynamic Programming**
**Solution 1: Dynamic Programming**

We define $left[i]$ as the height of the highest pillar to the left of and including the position with index $i$, and define $right[i]$ as the height of the highest pillar to the right of and including the position with index $i$. Then the amount of rain water that can be trapped at the position with index $i$ is $min(left[i], right[i]) - height[i]$. We traverse the array, calculate $left[i]$ and $right[i]$, and the answer is $\sum_{i=0}^{n-1} min(left[i], right[i]) - height[i]$.

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0045.Jump Game II/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

## Solutions

**Approach 1: Greedy**
**Solution 1: Greedy**

We can use a variable $mx$ to record the furthest position that can be reached at the current position, and use a variable $last$ to record the last jump position, and use a variable $ans$ to record the number of jumps.

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0048.Rotate Image/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

## Solutions

**Approach 1: In-place**
**Solution 1: In-place**

According to the requirements of the problem, we actually need to rotate $matrix[i][j]$ to $matrix[j][n - i - 1]$.

Expand Down
4 changes: 2 additions & 2 deletions solution/0000-0099/0054.Spiral Matrix/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@

## Solutions

**Approach 1: Simulation**
**Solution 1: Simulation**

We use $i$ and $j$ to respectively represent the row and column of the current element being visited, and use $k$ to represent the current direction. We use an array or hash table $vis$ to record whether each element has been visited. After each element is visited, it is marked as visited, and then the current direction is moved forward one step. If the forward step goes out of bounds or has been visited, the direction is changed and continued. Move forward until the entire matrix is traversed.

The time complexity is $O(m \times n)$ and the space complexity is $O(m \times n)$. Where $m$ and $n$ are the number of rows and columns of the matrix.

For the visited elements, we can also add a constant $300$ to their values, so we do not need an extra $vis$ array or hash table to record whether it has been visited, thus reducing the space complexity to $O(1)$.

**Approach 2: Layer-by-layer Simulation**
**Solution 2: Layer-by-layer Simulation**

We can also traverse and store the matrix elements from the outside to the inside layer by layer.

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0055.Jump Game/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

## Solutions

**Approach 1: Greedy**
**Solution 1: Greedy**

We use a variable $mx$ to maintain the farthest index that can be reached, initially $mx = 0$.

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0058.Length of Last Word/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

## Solutions

**Approach 1: Reverse traversal + two pointers**
**Solution 1: Reverse traversal + two pointers**

We start traversing from the end of the string $s$, finding the last character of the last word, which is not a space, and the subscript is $i$. Then continue to traverse forward to find the first space character, which is the character before the first character of the last word, and mark it as $j$. Then the length of the last word is $i - j$.

Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0071.Simplify Path/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

## Solutions

**Approach 1: Stack**
**Solution 1: Stack**

We first split the path into a number of substrings split by `'/'`. Then, we traverse each substring and perform the following operations based on the content of the substring:

Expand Down
4 changes: 2 additions & 2 deletions solution/0000-0099/0073.Set Matrix Zeroes/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@

## Solutions

**Approach 1: Array Mark**
**Solution 1: Array Mark**

We use arrays `rows` and `cols` to mark the rows and columns to be cleared.

Then traverse the matrix again, and clear the elements in the rows and columns marked in `rows` and `cols`.

The time complexity is $O(m\times n)$, and the space complexity is $O(m+n)$. Where $m$ and $n$ are the number of rows and columns of the matrix respectively.

**Approach 2: Mark in Place**
**Solution 2: Mark in Place**

In the first method, we use an additional array to mark the rows and columns to be cleared. In fact, we can also use the first row and first column of the matrix to mark them, without creating an additional array.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Since the largest window of s only has one &#39;a&#39;, return empty string.

## Solutions

**Approach 1: Counting + Two Pointers**
**Solution 1: Counting + Two Pointers**

We use a hash table or array $need$ to count the number of characters in string $t$, and use another hash table or array $window$ to count the number of characters in the sliding window. In addition, define two pointers $j$ and $i$ pointing to the left and right boundaries of the window, and the variable $cnt$ represents the number of characters in $t$ that are already included in the window. The variables $k$ and $mi$ represent the starting position and length of the minimum cover substring respectively.

Expand Down
Loading