t_char_to_count;
- for (char character : t) {
- t_char_to_count[character]++;
- }
-
- return s_char_to_count == t_char_to_count;
- }
-};
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [242. Valid Anagram - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/242-valid-anagram) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/26-remove-duplicates-from-sorted-array.md b/en/1-1000/26-remove-duplicates-from-sorted-array.md
deleted file mode 100644
index b3f6b3e..0000000
--- a/en/1-1000/26-remove-duplicates-from-sorted-array.md
+++ /dev/null
@@ -1,213 +0,0 @@
-# 26. Remove Duplicates from Sorted Array - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [26. Remove Duplicates from Sorted Array - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/26-remove-duplicates-from-sorted-array) for a better experience!
-
-LeetCode link: [26. Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array), difficulty: **Easy**.
-
-## LeetCode description of "26. Remove Duplicates from Sorted Array"
-
-Given an integer array `nums` sorted in **non-decreasing** order, remove the duplicates [in-place](https://en.wikipedia.org/wiki/In-place_algorithm) such that each unique element appears only **once**. The **relative order** of the elements should be kept the **same**. Then return _the number of unique elements in `nums`_.
-
-Consider the number of unique elements of `nums` to be `k`, to get accepted, you need to do the following things:
-
-- Change the array `nums` such that the first `k` elements of `nums` contain the unique elements in the order they were present in `nums` initially. The remaining elements of `nums` are not important as well as the size of `nums`.
-- Return `k`.
-
-### [Example 1]
-
-**Input**: `nums = [1,1,2]`
-
-**Output**: `2, nums = [1,2,_]`
-
-**Explanation**:
-
-Your function should return k = 2, with the first two elements of nums being 1 and 2 respectively.
-
-It does not matter what you leave beyond the returned k (hence they are underscores).
-
-
-### [Example 2]
-
-**Input**: `nums = [0,0,1,1,1,2,2,3,3,4]`
-
-**Output**: `5, nums = [0,1,2,3,4,_,_,_,_,_]`
-
-**Explanation**:
-
-Your function should return k = 5, with the first five elements of nums being 0, 1, 2, 3, and 4 respectively.
-
-It does not matter what you leave beyond the returned k (hence they are underscores).
-
-
-### [Constraints]
-
-- `1 <= nums.length <= 3 * 10^4`
-- `-10^4 <= nums[i] <= 10^4`
-- `nums` is sorted in **non-decreasing** order.
-
-### [Hints]
-
-
- Hint 1
- In this problem, the key point to focus on is the input array being sorted. As far as duplicate elements are concerned, what is their positioning in the array when the given array is sorted? Look at the image below for the answer. If we know the position of one of the elements, do we also know the positioning of all the duplicate elements?
-
-
-
-
-
- Hint 2
- We need to modify the array in-place and the size of the final array would potentially be smaller than the size of the input array. So, we ought to use a two-pointer approach here. One, that would keep track of the current element in the original array and another one for just the unique elements.
-
-
-
-
-
- Hint 3
- Essentially, once an element is encountered, you simply need to **bypass** its duplicates and move on to the next unique element.
-
-
-
-
-
-## Intuition
-
-The numbers in the array are already sorted, so any duplicate values must appear consecutively.
-
-To remove duplicates, we need to keep every number that is different from the previous one, and discard the rest.
-
-Since the array needs to be modified in place, two pointers are required: one moves fast and the other moves slow.
-
-the fast pointer increases its position by 1 each time, while the slow pointer marks the current position to be modified.
-
-## Pattern of "Fast & Slow Pointers Technique"
-
-```java
-int slow = 0; // slow pointer
-// ...
-
-for (int fast = 1; fast < array_length; fast++) { // This line is the key!
- if (condition_1) {
- // ...
- continue; // 'continue' is better than 'else' because 'else' will introduce more indents
- }
-
- if (condition_2) {
- // ...
- continue; // 'continue' is better than 'else'
- }
-
- // condition_3
- // ...
- slow++;
- // ...
-}
-
-return something;
-```
-
-## Complexity
-
-- Time complexity: `O(N)`.
-- Space complexity: `O(1)`.
-
-## Python
-
-```python
-class Solution:
- def removeDuplicates(self, nums: List[int]) -> int:
- slow = 1
-
- # nums = [0,0,1,1,1,2,2,3,3,4]
- for fast in range(1, len(nums)):
- if nums[fast] == nums[slow - 1]:
- continue
-
- nums[slow] = nums[fast]
- slow += 1
-
- return slow
-
-```
-
-## Ruby
-
-```ruby
-# @param {Integer[]} nums
-# @return {Integer}
-def remove_duplicates(nums)
- slow = 1
-
- # nums = [0,0,1,1,1,2,2,3,3,4]
- (1...nums.size).each do |fast|
- if nums[fast] == nums[slow - 1]
- next
- end
-
- nums[slow] = nums[fast]
- slow += 1
- end
-
- slow
-end
-```
-
-## Java
-
-```java
-class Solution {
- public int removeDuplicates(int[] nums) {
- var slow = 1;
-
- // nums = [0,0,1,1,1,2,2,3,3,4]
- for (var fast = 1; fast < nums.length; fast++) {
- if (nums[fast] != nums[slow - 1]) {
- nums[slow] = nums[fast];
- slow++;
- }
- }
-
- return slow;
- }
-}
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [26. Remove Duplicates from Sorted Array - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/26-remove-duplicates-from-sorted-array) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/27-remove-element.md b/en/1-1000/27-remove-element.md
deleted file mode 100644
index bc04401..0000000
--- a/en/1-1000/27-remove-element.md
+++ /dev/null
@@ -1,464 +0,0 @@
-# 27. Remove Element - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [27. Remove Element - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/27-remove-element) for a better experience!
-
-LeetCode link: [27. Remove Element](https://leetcode.com/problems/remove-element), difficulty: **Easy**.
-
-## LeetCode description of "27. Remove Element"
-
-Given an integer array `nums` and an integer `val`, remove all occurrences of `val` in `nums` [in-place](https://en.wikipedia.org/wiki/In-place_algorithm). The order of the elements may be changed. Then return *the number of elements in `nums` which are not equal to `val`*.
-
-Consider the number of elements in `nums` which are not equal to `val` be `k`, to get accepted, you need to do the following things:
-
-- Change the array `nums` such that the first `k` elements of `nums` contain the elements which are not equal to `val`. The remaining elements of `nums` are not important as well as the size of `nums`.
-- Return `k`.
-
-### [Example 1]
-
-**Input**: `nums = [3,2,2,3], val = 3`
-
-**Output**: `2, nums = [2,2,_,_]`
-
-**Explanation**:
-
-Your function should return k = 2, with the first two elements of nums being 2.
-It does not matter what you leave beyond the returned k (hence they are underscores).
-
-
-### [Example 2]
-
-**Input**: `nums = [0,1,2,2,3,0,4,2], val = 2`
-
-**Output**: `5, nums = [0,1,4,0,3,_,_,_]`
-
-**Explanation**:
-
-Your function should return k = 5, with the first five elements of nums containing 0, 0, 1, 3, and 4.
-Note that the five elements can be returned in any order.
-It does not matter what you leave beyond the returned k (hence they are underscores).
-
-
-### [Constraints]
-
-- `0 <= nums.length <= 100`
-- `0 <= nums[i] <= 50`
-- `0 <= val <= 100`
-
-### [Hints]
-
-
- Hint 1
- The problem statement clearly asks us to modify the array in-place and it also says that the element beyond the new length of the array can be anything. Given an element, we need to remove all the occurrences of it from the array. We don't technically need to **remove** that element per-say, right?
-
-
-
-
-
- Hint 2
- We can move all the occurrences of this element to the end of the array. Use two pointers!
-
- 
-
-
-
- Hint 3
- Yet another direction of thought is to consider the elements to be removed as non-existent. In a single pass, if we keep copying the visible elements in-place, that should also solve this problem for us.
-
-
-
-
-## Intuition 1
-
-- `Two pointers`, one on the left and one on the right. The left one points to the head of the array, and the right one points to the tail of the array.
-- If the value pointed by the left pointer is found to be equal to **val**, and the value pointed by the right pointer is not equal to *val*, then swap the two the values.
-- This method is easy to think of, but the amount of code is more than the `fast and slow pointers`.
-
-## Complexity
-
-- Time complexity: `O(N)`.
-- Space complexity: `O(1)`.
-
-## Java
-
-```java
-class Solution {
- public int removeElement(int[] nums, int val) {
- var left = 0;
- var right = nums.length - 1;
-
- while (left <= right) {
- if (nums[left] != val) {
- left += 1;
- continue;
- }
-
- if (nums[right] == val) {
- right -= 1;
- continue;
- }
-
- nums[left] = nums[right];
- left += 1;
- right -= 1;
- }
-
- return left;
- }
-}
-```
-
-## Python
-
-```python
-class Solution:
- def removeElement(self, nums: List[int], val: int) -> int:
- left = 0
- right = len(nums) - 1
-
- while left <= right:
- if nums[left] != val:
- left += 1
- continue
-
- if nums[right] == val:
- right -= 1
- continue
-
- nums[left] = nums[right]
- left += 1
- right -= 1
-
- return left
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- int removeElement(vector& nums, int val) {
- int left = 0;
- int right = nums.size() - 1;
-
- while (left <= right) {
- if (nums[left] != val) {
- left += 1;
- continue;
- }
-
- if (nums[right] == val) {
- right -= 1;
- continue;
- }
-
- nums[left] = nums[right];
- left += 1;
- right -= 1;
- }
-
- return left;
- }
-};
-```
-
-## JavaScript
-
-```javascript
-var removeElement = function (nums, val) {
- let left = 0
- let right = nums.length - 1
-
- while (left <= right) {
- if (nums[left] != val) {
- left += 1
- continue
- }
-
- if (nums[right] == val) {
- right -= 1
- continue
- }
-
- nums[left] = nums[right]
- left += 1
- right -= 1
- }
-
- return left
-};
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- public int RemoveElement(int[] nums, int val)
- {
- int left = 0;
- int right = nums.Length - 1;
-
- while (left <= right)
- {
- if (nums[left] != val)
- {
- left += 1;
- continue;
- }
-
- if (nums[right] == val)
- {
- right -= 1;
- continue;
- }
-
- nums[left] = nums[right];
- left += 1;
- right -= 1;
- }
-
- return left;
- }
-}
-```
-
-## Go
-
-```go
-func removeElement(nums []int, val int) int {
- left := 0
- right := len(nums) - 1
-
- for left <= right {
- if nums[left] != val {
- left += 1
- continue
- }
-
- if nums[right] == val {
- right -= 1
- continue
- }
-
- nums[left] = nums[right]
- left++
- right--
- }
-
- return left
-}
-```
-
-## Ruby
-
-```ruby
-def remove_element(nums, val)
- left = 0
- right = nums.size - 1
-
- while left <= right
- if nums[left] != val
- left += 1
- next
- end
-
- if (nums[right] == val)
- right -= 1
- next
- end
-
- nums[left] = nums[right]
- left += 1
- right -= 1
- end
-
- left
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Intuition 2
-
-- The `fast and slow pointer approach` means that both pointers initially point to the head of the array, and then one pointer moves faster.
-- For this question, under what circumstances should the fast pointer move faster? When the value corresponding to the fast pointer is equal to *val*. The slow pointer must ensure that each value it passes through is not equal to *val*.
-- The swap of values occurs when the value pointed by the fast pointer is not equal to *val*, and the value pointed by the slow pointer is equal to *val*.
-- This method is not easy to think of, but it is more concise than `two pointers of left and right`.
-
-## Complexity
-
-- Time complexity: `O(N)`.
-- Space complexity: `O(1)`.
-
-## Java
-
-```java
-class Solution {
- public int removeElement(int[] nums, int val) {
- var slowIndex = 0;
-
- for (var num : nums) { // This line is the most important. You'd better memorize it.
- if (num != val) {
- nums[slowIndex] = num;
- slowIndex += 1;
- }
- }
-
- return slowIndex;
- }
-}
-```
-
-## Python
-
-```python
-class Solution:
- def removeElement(self, nums: List[int], val: int) -> int:
- slow_index = 0
-
- for num in nums: # This line is the most important. You'd better memorize it.
- if num != val:
- nums[slow_index] = num
- slow_index += 1
-
- return slow_index
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- int removeElement(vector& nums, int val) {
- auto slow_index = 0;
-
- for (auto num : nums) { // This line is the most important. You'd better memorize it.
- if (num != val) {
- nums[slow_index] = num;
- slow_index += 1;
- }
- }
-
- return slow_index;
- }
-};
-```
-
-## JavaScript
-
-```javascript
-var removeElement = function (nums, val) {
- let slowIndex = 0
-
- nums.forEach((num) => { // This line is the most important. You'd better memorize it.
- if (num != val) {
- nums[slowIndex] = num
- slowIndex += 1
- }
- })
-
- return slowIndex
-};
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- public int RemoveElement(int[] nums, int val)
- {
- int slowIndex = 0;
-
- foreach (int num in nums) // This line is the most important. You'd better memorize it.
- {
- if (num != val)
- {
- nums[slowIndex] = num;
- slowIndex += 1;
- }
- }
-
- return slowIndex;
- }
-}
-```
-
-## Go
-
-```go
-func removeElement(nums []int, val int) int {
- slowIndex := 0
-
- for _, num := range nums { // This line is the most important. You'd better memorize it.
- if num != val {
- nums[slowIndex] = num
- slowIndex += 1
- }
- }
-
- return slowIndex
-}
-```
-
-## Ruby
-
-```ruby
-def remove_element(nums, val)
- slow_index = 0
-
- nums.each do |num| # This line is the most important. You'd better memorize it.
- if num != val
- nums[slow_index] = num
- slow_index += 1
- end
- end
-
- slow_index
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [27. Remove Element - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/27-remove-element) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/279-perfect-squares.md b/en/1-1000/279-perfect-squares.md
deleted file mode 100644
index d446efd..0000000
--- a/en/1-1000/279-perfect-squares.md
+++ /dev/null
@@ -1,178 +0,0 @@
-# 279. Perfect Squares
-LeetCode link: [279. Perfect Squares](https://leetcode.com/problems/perfect-squares/)
-
-## LeetCode problem description
-> Given an integer `n`, return the **least** number of perfect square numbers that sum to `n`.
-
-A **perfect square** is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, `1`, `4`, `9`, and 16 are perfect squares while `3` and `11` are not.
-```
--------------------------------------------------------------
-[Example 1]
-
-Input: n = 12
-Output: 3
-Explanation: 12 = 4 + 4 + 4.
--------------------------------------------------------------
-[Example 2]
-
-Input: n = 13
-Output: 2
-Explanation: 13 = 4 + 9.
--------------------------------------------------------------
-[Constraints]
-
-1 <= n <= 10000
--------------------------------------------------------------
-```
-
-## Thoughts
-It is a `Unbounded Knapsack Problem`.
-
-Detailed solutions will be given later, and now only the best practices in 7 languages are given.
-
-### Complexity
-* Time: `O(n * Sqrt(n))`.
-* Space: `O(n)`.
-
-## C#
-```c#
-public class Solution
-{
- public int NumSquares(int n)
- {
- int defaultValue = n + 2; // As long as the value is greater than 'n', it doesn't matter how much it is.
- int[] dp = Enumerable.Repeat(defaultValue, n + 1).ToArray();
- dp[0] = 0;
-
- for (var i = 1; i < dp.Length; i++)
- {
- for (var j = 1; j * j <= i; j++)
- {
- dp[i] = Math.Min(dp[i], dp[i - j * j] + 1);
- }
- }
-
- return dp.Last();
- }
-}
-```
-
-## Python
-```python
-class Solution:
- def numSquares(self, n: int) -> int:
- default_value = n + 2 # As long as the value is greater than 'n', it doesn't matter how much it is.
- dp = [default_value] * (n + 1)
- dp[0] = 0
-
- for i in range(1, len(dp)):
- j = 1
- while i >= j * j:
- dp[i] = min(dp[i], dp[i - j * j] + 1)
- j += 1
-
- return dp[-1]
-```
-
-## C++
-```cpp
-class Solution {
-public:
- int numSquares(int n) {
- auto default_value = n + 2; // As long as the value is greater than 'n', it doesn't matter how much it is.
- auto dp = vector(n + 1, default_value);
- dp[0] = 0;
-
- for (auto i = 1; i < dp.size(); i++) {
- for (auto j = 1; j * j <= i; j++) {
- dp[i] = min(dp[i], dp[i - j * j] + 1);
- }
- }
-
- return dp.back();
- }
-};
-```
-
-## Java
-```java
-class Solution {
- public int numSquares(int n) {
- var defaultValue = n + 2; // As long as the value is greater than 'n', it doesn't matter how much it is.
- var dp = new int[n + 1];
- Arrays.fill(dp, defaultValue);
- dp[0] = 0;
-
- for (var i = 1; i < dp.length; i++) {
- for (var j = 1; j * j <= i; j++) {
- dp[i] = Math.min(dp[i], dp[i - j * j] + 1);
- }
- }
-
- return dp[dp.length - 1];
- }
-}
-```
-
-## JavaScript
-```javascript
-var numSquares = function (n) {
- const DEFAULT_VALUE = n + 2 // As long as the value is greater than 'n', it doesn't matter how much it is.
- const dp = Array(n + 1).fill(DEFAULT_VALUE)
- dp[0] = 0
-
- for (let i = 1; i < dp.length; i++) {
- for (let j = 1; j * j <= i; j++) {
- dp[i] = Math.min(dp[i], dp[i - j * j] + 1)
- }
- }
-
- return dp.at(-1)
-};
-```
-
-## Go
-```go
-func numSquares(n int) int {
- defaultValue := n + 2 // As long as the value is greater than 'n', it doesn't matter how much it is.
- dp := slices.Repeat([]int{defaultValue}, n + 1)
- dp[0] = 0
-
- for i := 1; i < len(dp); i++ {
- for j := 1; j * j <= i; j++ {
- dp[i] = min(dp[i], dp[i - j * j] + 1)
- }
- }
-
- return dp[len(dp) - 1]
-}
-```
-
-## Ruby
-```ruby
-def num_squares(n)
- default_value = n + 2 # As long as the value is greater than 'n', it doesn't matter how much it is.
- dp = Array.new(n + 1, default_value)
- dp[0] = 0
-
- (1...dp.size).each do |i|
- j = 1
- while i >= j * j
- dp[i] = [ dp[i], dp[i - j * j] + 1 ].min
- j += 1
- end
- end
-
- dp[-1]
-end
-```
-
-## Rust
-```rust
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Other languages
-```
-// Welcome to create a PR to complete the code of this language, thanks!
-```
diff --git a/en/1-1000/28-find-the-index-of-the-first-occurrence-in-a-string.md b/en/1-1000/28-find-the-index-of-the-first-occurrence-in-a-string.md
deleted file mode 100644
index d846a43..0000000
--- a/en/1-1000/28-find-the-index-of-the-first-occurrence-in-a-string.md
+++ /dev/null
@@ -1,233 +0,0 @@
-# 28. Find the Index of the First Occurrence in a String - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [28. Find the Index of the First Occurrence in a String - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/28-find-the-index-of-the-first-occurrence-in-a-string) for a better experience!
-
-LeetCode link: [28. Find the Index of the First Occurrence in a String](https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string), difficulty: **Easy**.
-
-## LeetCode description of "28. Find the Index of the First Occurrence in a String"
-
-Given two strings `needle` and `haystack`, return the **index** of the first occurrence of `needle` in `haystack`, or `-1` if `needle` is not part of `haystack`.
-
-### [Example 1]
-
-**Input**: `haystack = "sadbutsad", needle = "sad"`
-
-**Output**: `0`
-
-**Explanation**:
-
-"sad" occurs at index 0 and 6.
-The first occurrence is at index 0, so we return 0.
-
-
-### [Example 2]
-
-**Input**: `haystack = "leetcode", needle = "leeto"`
-
-**Output**: `-1`
-
-**Explanation**:
-
-"leeto" did not occur in "leetcode", so we return -1.
-
-
-### [Constraints]
-
-- `1 <= haystack.length, needle.length <= 10000`
-- `haystack` and `needle` consist of only lowercase English characters.
-
-## Intuition
-
-- This kind of question can be solved with one line of code using the built-in `index()`. Obviously, the questioner wants to test our ability to control the loop.
-
-- For `heystack`, iterate through each character in turn. If the substring from the current character to `needle` is the same as `needle`, return the position of the current character.
-
-- This question is easier to understand by looking at the code directly.
-
-## Complexity
-
-- Time complexity: `O(N * M)`.
-- Space complexity: `O(1)`.
-
-## Python
-
-```python
-class Solution:
- def strStr(self, haystack: str, needle: str) -> int:
- n = len(haystack)
- m = len(needle)
-
- for i in range(n - m + 1):
- if haystack[i:i + m] == needle:
- return i
-
- return -1
-```
-
-## JavaScript
-
-```javascript
-/**
- * @param {string} haystack
- * @param {string} needle
- * @return {number}
- */
-var strStr = function(haystack, needle) {
- const n = haystack.length;
- const m = needle.length;
-
- for (let i = 0; i <= n - m; i++) {
- if (haystack.substring(i, i + m) === needle) {
- return i;
- }
- }
-
- return -1;
-};
-
-```
-
-## Ruby
-
-```ruby
-# @param {String} haystack
-# @param {String} needle
-# @return {Integer}
-def str_str(haystack, needle)
- (0..haystack.size - needle.size).each do |i|
- if haystack[i...i + needle.size] == needle
- return i
- end
- end
-
- -1
-end
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- int strStr(string haystack, string needle) {
- for (int i = 0; i < haystack.length(); i++) {
- int j = 0;
-
- while (i + j < haystack.length() && haystack[i + j] == needle[j]) {
- j++;
-
- if (j == needle.length()) {
- return i;
- }
- }
- }
-
- return -1;
- }
-};
-```
-
-## Java
-
-```java
-class Solution {
- public int strStr(String haystack, String needle) {
- for (int i = 0; i < haystack.length(); i++) {
- int j = 0;
-
- while (i + j < haystack.length() && haystack.charAt(i + j) == needle.charAt(j)) {
- j++;
-
- if (j == needle.length()) {
- return i;
- }
- }
- }
-
- return -1;
- }
-}
-```
-
-## Go
-
-```go
-func strStr(haystack string, needle string) int {
- for i := 0; i < len(haystack); i++ {
- j := 0
-
- for i+j < len(haystack) && haystack[i+j] == needle[j] {
- j++
-
- if j == len(needle) {
- return i
- }
- }
- }
-
- return -1
-}
-```
-
-## C#
-
-```csharp
-public class Solution {
- public int StrStr(string haystack, string needle) {
- for (int i = 0; i < haystack.Length; i++) {
- int j = 0;
-
- while (i + j < haystack.Length && haystack[i + j] == needle[j]) {
- j++;
-
- if (j == needle.Length) {
- return i;
- }
- }
- }
-
- return -1;
- }
-}
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [28. Find the Index of the First Occurrence in a String - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/28-find-the-index-of-the-first-occurrence-in-a-string) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/300-longest-increasing-subsequence.md b/en/1-1000/300-longest-increasing-subsequence.md
deleted file mode 100644
index b5ca3bf..0000000
--- a/en/1-1000/300-longest-increasing-subsequence.md
+++ /dev/null
@@ -1,143 +0,0 @@
-# 300. Longest Increasing Subsequence
-LeetCode link: [300. Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence/)
-
-## LeetCode problem description
-Given an integer array `nums`, return the length of the **longest strictly increasing subsequence**.
-
-```
--------------------------------------------------------------------------------------------
-[Example 1]
-
-Input: nums = [10,9,2,5,3,7,101,18]
-Output: 4
-
-Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4.
--------------------------------------------------------------------------------------------
-[Example 2]
-
-Input: nums = [0,1,0,3,2,3]
-Output: 4
--------------------------------------------------------------------------------------------
-[Example 3]
-
-Input: nums = [7,7,7,7,7,7,7]
-Output: 1
--------------------------------------------------------------------------------------------
-[Constraints]
-
-1 <= nums.length <= 2500
--10000 <= nums[i] <= 10000
--------------------------------------------------------------------------------------------
-```
-
-## Thoughts
-This problem can be solved using **Dynamic programming**.
-
-Detailed solutions will be given later, and now only the best practices in 4 to 7 languages are given.
-
-### Complexity
-* Time: `O(n * n)`.
-* Space: `O(n)`.
-
-## C#
-```c#
-// 10, 9, 2, 5, 3, 7, 4, 3,101,18 # nums
-// 1, 1, 1, 2, 2, 3, 3, 2, 4,4 # dp
-public class Solution
-{
- public int LengthOfLIS(int[] nums)
- {
- var dp = new int[nums.Length];
- Array.Fill(dp, 1);
-
- for (var i = 1; i < nums.Length; i++)
- {
- for (var j = i - 1; j >= 0; j--)
- {
- if (nums[i] > nums[j])
- {
- dp[i] = Math.Max(dp[i], dp[j] + 1);
- }
- }
- }
-
- return dp.Max();
- }
-}
-```
-
-## Python
-```python
-class Solution:
- def lengthOfLIS(self, nums: List[int]) -> int:
- dp = [1] * len(nums)
-
- for i in range(1, len(dp)):
- for j in range(i - 1, -1, -1):
- if nums[i] > nums[j] and dp[j] + 1 > dp[i]:
- dp[i] = dp[j] + 1
-
- return max(dp)
-```
-
-## C++
-```cpp
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Java
-```java
-class Solution {
- public int lengthOfLIS(int[] nums) {
- var dp = new int[nums.length];
- Arrays.fill(dp, 1);
-
- for (var i = 1; i < nums.length; i++) {
- for (var j = i - 1; j >= 0; j--) {
- if (nums[i] > nums[j]) {
- dp[i] = Math.max(dp[i], dp[j] + 1);
- }
- }
- }
-
- return IntStream.of(dp).max().getAsInt();
- }
-}
-```
-
-## JavaScript
-```javascript
-var lengthOfLIS = function (nums) {
- const dp = Array(nums.length).fill(1)
-
- nums.forEach((num, i) => {
- for (let j = i - 1; j >= 0; j--) {
- if (num > nums[j]) {
- dp[i] = Math.max(dp[i], dp[j] + 1)
- }
- }
- })
-
- return Math.max(...dp)
-};
-```
-
-## Go
-```go
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Ruby
-```ruby
-# Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Rust
-```rust
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Other languages
-```
-// Welcome to create a PR to complete the code of this language, thanks!
-```
diff --git a/en/1-1000/303-range-sum-query-immutable.md b/en/1-1000/303-range-sum-query-immutable.md
deleted file mode 100644
index 0151459..0000000
--- a/en/1-1000/303-range-sum-query-immutable.md
+++ /dev/null
@@ -1,268 +0,0 @@
-# 303. Range Sum Query - Immutable - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [303. Range Sum Query - Immutable - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/303-range-sum-query-immutable) for a better experience!
-
-LeetCode link: [303. Range Sum Query - Immutable](https://leetcode.com/problems/range-sum-query-immutable), difficulty: **Easy**.
-
-## LeetCode description of "303. Range Sum Query - Immutable"
-
-Given an integer array `nums`, handle multiple queries of the following type:
-
-1. Calculate the sum of the elements of `nums` between indices `left` and `right` inclusive where `left <= right`.
-
-Implement the `NumArray` class:
-
-- `NumArray(int[] nums)` Initializes the object with the integer array `nums`.
-- `int sumRange(int left, int right)` Returns the **sum** of the elements of `nums` between indices `left` and `right` **inclusive** (i.e. `nums[left] + nums[left + 1] + ... + nums[right]`).
-
-### [Example 1]
-
-**Input**: `["NumArray", "sumRange", "sumRange", "sumRange"] [[[-2, 0, 3, -5, 2, -1]], [0, 2], [2, 5], [0, 5]]`
-
-**Output**: `[null, 1, -1, -3]`
-
-**Explanation**:
-
-NumArray numArray = new NumArray([-2, 0, 3, -5, 2, -1]);
-numArray.sumRange(0, 2); // return (-2) + 0 + 3 = 1
-numArray.sumRange(2, 5); // return 3 + (-5) + 2 + (-1) = -1
-numArray.sumRange(0, 5); // return (-2) + 0 + 3 + (-5) + 2 + (-1) = -3
-
-
-### [Constraints]
-
-- `1 <= nums.length <= 10^4`
-- `-10^5 <= nums[i] <= 10^5`
-- `0 <= left <= right < nums.length`
-- At most `10^4` calls will be made to `sumRange`.
-
-## Intuition 1
-
-- Use a new array `prefix_sums` to save the sum of the previous elements.
-- The first element of `prefix_sums` is `0` because the prefix sum **does not include the current element**.
-- To find the `sum` of the elements from index `left` to `right` (inclusive), just use `prefix_sums[right + 1] - prefix_sums[left]`.
-
-## Complexity
-
-- Time complexity: `O(N)`.
-- Space complexity: `O(N)`.
-
-## Java
-
-```java
-class NumArray {
- private int[] prefixSums;
-
- public NumArray(int[] nums) {
- prefixSums = new int[nums.length + 1];
- var sum = 0;
-
- for (var i = 0; i < nums.length; i++) {
- sum += nums[i];
- prefixSums[i + 1] = sum;
- }
- }
-
- public int sumRange(int left, int right) {
- return prefixSums[right + 1] - prefixSums[left];
- }
-}
-```
-
-## Python
-
-```python
-class NumArray:
- def __init__(self, nums: List[int]):
- self.prefix_sums = [0]
- sum_ = 0
-
- for num in nums:
- sum_ += num
- self.prefix_sums.append(sum_)
-
- def sumRange(self, left: int, right: int) -> int:
- return self.prefix_sums[right + 1] - self.prefix_sums[left]
-```
-
-## C++
-
-```cpp
-class NumArray {
-private:
- vector prefixSums;
-
-public:
- NumArray(vector& nums) {
- prefixSums.push_back(0);
- auto sum = 0;
-
- for (auto num : nums) {
- sum += num;
- prefixSums.push_back(sum);
- }
- }
-
- int sumRange(int left, int right) {
- return prefixSums[right + 1] - prefixSums[left];
- }
-};
-```
-
-## JavaScript
-
-```javascript
-let prefixSums
-
-var NumArray = function (nums) {
- prefixSums = [0]
- let sum = 0
-
- nums.forEach((num) => {
- sum += num
- prefixSums.push(sum)
- })
-};
-
-NumArray.prototype.sumRange = function (left, right) {
- return prefixSums[right + 1] - prefixSums[left]
-};
-```
-
-## C#
-
-```csharp
-public class NumArray
-{
- int[] prefixSums;
-
- public NumArray(int[] nums)
- {
- prefixSums = new int[nums.Length + 1];
- int sum = 0;
-
- for (int i = 0; i < nums.Length; i++)
- {
- sum += nums[i];
- prefixSums[i + 1] = sum;
- }
- }
-
- public int SumRange(int left, int right)
- {
- return prefixSums[right + 1] - prefixSums[left];
- }
-}
-```
-
-## Go
-
-```go
-type NumArray struct {
- prefixSums []int
-}
-
-func Constructor(nums []int) NumArray {
- prefixSums := make([]int, len(nums) + 1)
- sum := 0
-
- for i, num := range nums {
- sum += num
- prefixSums[i + 1] = sum
- }
-
- return NumArray{prefixSums}
-}
-
-func (this *NumArray) SumRange(left int, right int) int {
- return this.prefixSums[right + 1] - this.prefixSums[left]
-}
-```
-
-## Ruby
-
-```ruby
-class NumArray
- def initialize(nums)
- @prefix_sums = [0]
- sum = 0
-
- nums.each do |num|
- sum += num
- @prefix_sums << sum
- end
- end
-
- def sum_range(left, right)
- @prefix_sums[right + 1] - @prefix_sums[left]
- end
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Intuition 2
-
-Directly returning the sum of the values in the array range can pass the test, but it will fail if the test case is stricter.
-So we still need to learn a more efficient solution: `Prefix Sum` solution.
-
-## Complexity
-
-- Time complexity: `O(M * N)`.
-- Space complexity: `O(M * N)`.
-
-## Python
-
-```python
-class NumArray:
- def __init__(self, nums: List[int]):
- self.nums = nums
-
- def sumRange(self, left: int, right: int) -> int:
- return sum(self.nums[left:right + 1])
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [303. Range Sum Query - Immutable - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/303-range-sum-query-immutable) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/309-best-time-to-buy-and-sell-stock-with-cooldown.md b/en/1-1000/309-best-time-to-buy-and-sell-stock-with-cooldown.md
deleted file mode 100644
index 547f3da..0000000
--- a/en/1-1000/309-best-time-to-buy-and-sell-stock-with-cooldown.md
+++ /dev/null
@@ -1,140 +0,0 @@
-# 309. Best Time to Buy and Sell Stock with Cooldown
-LeetCode link: [309. Best Time to Buy and Sell Stock with Cooldown](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/)
-
-## LeetCode problem description
-You are given an array `prices` where `prices[i]` is the price of a given stock on the `i-th` day.
-
-Find the **maximum profit** you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times) with the following restrictions:
-
-* After you sell your stock, you cannot buy stock on the next day (i.e., cooldown one day).
-
-**Note**: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).
-
-```
--------------------------------------------------------------------------
-[Example 1]
-
-Input: prices = [1,2,3,0,2]
-Output: 3
-
-Explanation: transactions = [buy, sell, cooldown, buy, sell]
--------------------------------------------------------------------------
-[Example 2]
-
-Input: prices = [1]
-Output: 0
--------------------------------------------------------------------------
-[Constraints]
-
-1 <= prices.length <= 5000
-0 <= prices[i] <= 1000
--------------------------------------------------------------------------
-```
-
-## Thoughts
-This problem can be solved using **Dynamic programming**.
-
-Detailed solutions will be given later, and now only the best practices in 3 to 7 languages are given.
-
-### Complexity
-* Time: `O(n)`.
-* Space: `O(n)`.
-
-## Python
-```python
-class Solution:
- def maxProfit(self, prices: List[int]) -> int:
- # 2 states:
- # 0: hold stock
- # 1) keep holding (last day is not a cooldown day)
- # 2) today just bought (last day is a cooldown day)
- # 1: no stock
- # 1) keep no stock (today is not a cooldown day)
- # 2) keep no stock (today is a cooldown day)
- # 3) today just sold
- #
- # To make things clear, we have to go with 3 states.
- # The process from 2 states to 3 states really makes things easier to understand!
- # 3 states:
- # 0: hold stock
- # 1) keep holding (last day is not a cooldown day)
- # 2) today just bought (last day is a cooldown day)
- # 1: no stock (today is not a cooldown day)
- # 1) keep no stock
- # 2) today just sold
- # 2: no stock (today is a cooldown day)
- dp = [-prices[0], 0, 0]
-
- for price in prices[1:]:
- dc = dp.copy()
-
- dp[0] = max(dc[0], dc[2] - price)
- dp[1] = max(dc[1], dc[0] + price)
- dp[2] = dc[1]
-
- return dp[1]
-```
-
-## C++
-```cpp
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Java
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## C#
-```c#
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## JavaScript
-```javascript
-var maxProfit = function(prices) {
- const dp = [-prices[0], 0, 0]
-
- for (const price of prices.slice(1,)) {
- const dc = [...dp]
-
- dp[0] = Math.max(dc[0], dc[2] - price)
- dp[1] = Math.max(dc[1], dc[0] + price)
- dp[2] = dc[1]
- }
-
- return dp[1]
-};
-```
-
-## Go
-```go
-func maxProfit(prices []int) int {
- dp := []int{-prices[0], 0, 0}
-
- for i := 1; i < len(prices); i++ {
- dc := slices.Clone(dp)
-
- dp[0] = max(dc[0], dc[2] - prices[i])
- dp[1] = max(dc[1], dc[0] + prices[i])
- dp[2] = dc[1]
- }
-
- return dp[1]
-}
-```
-
-## Ruby
-```ruby
-# Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Rust
-```rust
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Other languages
-```
-// Welcome to create a PR to complete the code of this language, thanks!
-```
diff --git a/en/1-1000/322-coin-change.md b/en/1-1000/322-coin-change.md
deleted file mode 100644
index fbca4eb..0000000
--- a/en/1-1000/322-coin-change.md
+++ /dev/null
@@ -1,214 +0,0 @@
-# 322. Coin Change
-LeetCode link: [322. Coin Change](https://leetcode.com/problems/coin-change/)
-
-## LeetCode problem description
-> You are given an integer array `coins` representing coins of different denominations and an integer `amount` representing a total amount of money.
-
-Return the **fewest number** of coins that you need to make up that `amount`. If that amount of money cannot be made up by any combination of the coins, return `-1`.
-
-You may assume that you have an **infinite** number of each kind of coin.
-
-```
-Example 1:
-
-Input: coins = [1,2,5], amount = 11
-Output: 3
-
-Explanation: 11 = 5 + 5 + 1
-------------------------------------------------------------------------
-
-Example 2:
-
-Input: coins = [2], amount = 3
-Output: -1
-------------------------------------------------------------------------
-
-Constraints:
-
-1 <= coins.length <= 12
-1 <= coins[i] <= 2**31 - 1
-0 <= amount <= 10000
-```
-
-## Thoughts
-It is a `Unbounded Knapsack Problem`.
-
-Detailed solutions will be given later, and now only the best practices in 7 languages are given.
-
-### Complexity
-* Time: `O(n * m)`.
-* Space: `O(n)`.
-
-## C#
-```c#
-public class Solution
-{
- public int CoinChange(int[] coins, int amount)
- {
- int defaultValue = amount + 2; // As long as the value is greater than 'amount', it doesn't matter how much it is.
- int[] dp = Enumerable.Repeat(defaultValue, amount + 1).ToArray();
- dp[0] = 0;
-
- for (var i = 1; i < dp.Length; i++)
- {
- foreach (int coin in coins)
- {
- if (i >= coin)
- {
- dp[i] = Math.Min(dp[i], dp[i - coin] + 1);
- }
- }
- }
-
- if (dp.Last() == defaultValue)
- return -1;
-
- return dp.Last();
- }
-}
-```
-
-## Python
-```python
-class Solution:
- def coinChange(self, coins: List[int], amount: int) -> int:
- default_value = amount + 2 # As long as the value is greater than 'amount', it doesn't matter how much it is.
- dp = [default_value] * (amount + 1)
- dp[0] = 0
-
- for i in range(1, len(dp)):
- for coin in coins:
- if i >= coin:
- dp[i] = min(dp[i], dp[i - coin] + 1)
-
- if dp[-1] == default_value:
- return -1
-
- return dp[-1]
-```
-
-## C++
-```cpp
-class Solution {
-public:
- int coinChange(vector& coins, int amount) {
- auto default_value = amount + 2; // As long as the value is greater than 'amount', it doesn't matter how much it is.
- auto dp = vector(amount + 1, default_value);
- dp[0] = 0;
-
- for (auto i = 1; i < dp.size(); i++) {
- for (auto coin : coins) {
- if (i >= coin) {
- dp[i] = min(dp[i], dp[i - coin] + 1);
- }
- }
- }
-
- if (dp.back() == default_value) {
- return -1;
- }
- return dp.back();
- }
-};
-```
-
-## Java
-```java
-class Solution {
- public int coinChange(int[] coins, int amount) {
- var defaultValue = amount + 2; // As long as the value is greater than 'amount', it doesn't matter how much it is.
-
- var dp = new int[amount + 1];
- Arrays.fill(dp, defaultValue);
- dp[0] = 0;
-
- for (var i = 1; i < dp.length; i++) {
- for (var coin : coins) {
- if (i >= coin) {
- dp[i] = Math.min(dp[i], dp[i - coin] + 1);
- }
- }
- }
-
- var result = dp[dp.length - 1];
- if (result == defaultValue) {
- return -1;
- }
- return result;
- }
-}
-```
-
-## JavaScript
-```javascript
-var coinChange = function (coins, amount) {
- const DEFAULT_VALUE = amount + 2 // As long as the value is greater than 'amount', it doesn't matter how much it is.
- const dp = Array(amount + 1).fill(DEFAULT_VALUE)
- dp[0] = 0
-
- for (let i = 1; i < dp.length; i++) {
- for (const coin of coins) {
- if (i >= coin) {
- dp[i] = Math.min(dp[i], dp[i - coin] + 1)
- }
- }
- }
-
- if (dp.at(-1) == DEFAULT_VALUE) {
- return -1
- }
- return dp.at(-1)
-};
-```
-
-## Go
-```go
-func coinChange(coins []int, amount int) int {
- defaultValue := amount + 2 // As long as the value is greater than 'amount', it doesn't matter how much it is.
- dp := slices.Repeat([]int{defaultValue}, amount + 1)
- dp[0] = 0
-
- for i := 1; i < len(dp); i++ {
- for _, coin := range coins {
- if i >= coin {
- dp[i] = min(dp[i], dp[i - coin] + 1)
- }
- }
- }
-
- result := dp[len(dp) - 1]
- if result == defaultValue {
- return -1
- }
- return result
-}
-```
-
-## Ruby
-```ruby
-def coin_change(coins, amount)
- default_value = amount + 2 # As long as the value is greater than 'amount', it doesn't matter how much it is.
- dp = Array.new(amount + 1, default_value)
- dp[0] = 0
-
- (1...dp.size).each do |i|
- coins.each do |coin|
- dp[i] = [ dp[i], dp[i - coin] + 1 ].min if i >= coin
- end
- end
-
- return -1 if dp[-1] == default_value
-
- dp[-1]
-end
-```
-
-## Rust
-```rust
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Other languages
-```
-// Welcome to create a PR to complete the code of this language, thanks!
-```
diff --git a/en/1-1000/334-increasing-triplet-subsequence.md b/en/1-1000/334-increasing-triplet-subsequence.md
deleted file mode 100644
index b34392d..0000000
--- a/en/1-1000/334-increasing-triplet-subsequence.md
+++ /dev/null
@@ -1,284 +0,0 @@
-# 334. Increasing Triplet Subsequence - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [334. Increasing Triplet Subsequence - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/334-increasing-triplet-subsequence) for a better experience!
-
-LeetCode link: [334. Increasing Triplet Subsequence](https://leetcode.com/problems/increasing-triplet-subsequence), difficulty: **Medium**.
-
-## LeetCode description of "334. Increasing Triplet Subsequence"
-
-Given an integer array `nums`, return `true` if there exists a triple of indices `(i, j, k)` such that `i < j < k` and `nums[i] < nums[j] < nums[k]`. If no such indices exists, return `false`.
-
-### [Example 1]
-
-**Input**: `nums = [1,2,3,4,5]`
-
-**Output**: `true`
-
-**Explanation**: `Any triplet where i < j < k is valid.`
-
-### [Example 2]
-
-**Input**: `nums = [5,4,3,2,1]`
-
-**Output**: `false`
-
-**Explanation**: `No triplet exists.`
-
-### [Example 3]
-
-**Input**: `nums = [2,1,5,0,4,6]`
-
-**Output**: `true`
-
-**Explanation**:
-
-The triplet (3, 4, 5) is valid because nums[3] == 0 < nums[4] == 4 < nums[5] == 6.
-
-
-### [Constraints]
-
-- `1 <= nums.length <= 5 * 10^5`
-- `-2^31 <= nums[i] <= 2^31 - 1`
-
-**Follow up**: Could you implement a solution that runs in `O(n)` time complexity and `O(1)` space complexity?
-
-## Intuition
-
-To find an increasing triplet subsequence, we can track the smallest and second-smallest elements seen so far. If we encounter an element larger than both, we've found our triplet.
-
-## Pattern of "Greedy Algorithm"
-
-The `Greedy Algorithm` is a strategy that makes the locally optimal choice at each step with the hope of leading to a "globally optimal" solution. In other words, "local optima" can result in "global optima."
-
-## Step-by-Step Solution
-
-1. Initialize `first` as the first element and `second` as infinity.
-2. Iterate through the array starting from the second element:
- - if current element > `second`, then triplet found → return `true`.
- - else (current element < `second`)
- - if current element > `first`, update `second` to current element.
- - else, update `first` to current element (keeping it the smallest seen so far).
-3. If loop completes without finding a triplet, return `false`.
-
-## Complexity
-
-- Time complexity: `O(N)`.
-- Space complexity: `O(1)`.
-
-## Python
-
-```python
-class Solution:
- def increasingTriplet(self, nums: List[int]) -> bool:
- first = nums[0]
- second = float('inf')
-
- for i in range(1, len(nums)):
- if nums[i] > second:
- return True
-
- # Here, nums[i] <= second
- if nums[i] > first:
- second = nums[i]
- else:
- first = nums[i]
-
- return False
-```
-
-## Java
-
-```java
-class Solution {
- public boolean increasingTriplet(int[] nums) {
- int first = nums[0];
- int second = Integer.MAX_VALUE;
-
- for (int i = 1; i < nums.length; i++) {
- if (nums[i] > second) {
- return true;
- }
-
- // Here, nums[i] <= second
- if (nums[i] > first) {
- second = nums[i];
- } else {
- first = nums[i];
- }
- }
- return false;
- }
-}
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- bool increasingTriplet(vector& nums) {
- int first = nums[0];
- int second = INT_MAX;
-
- for (int i = 1; i < nums.size(); i++) {
- if (nums[i] > second) {
- return true;
- }
-
- // Here, nums[i] <= second
- if (nums[i] > first) {
- second = nums[i];
- } else {
- first = nums[i];
- }
- }
-
- return false;
- }
-};
-```
-
-## JavaScript
-
-```javascript
-/**
- * @param {number[]} nums
- * @return {boolean}
- */
-var increasingTriplet = function (nums) {
- let first = nums[0]
- let second = Infinity
-
- for (let i = 1; i < nums.length; i++) {
- if (nums[i] > second) {
- return true
- }
-
- // Here, nums[i] <= second
- if (nums[i] > first) {
- second = nums[i]
- } else {
- first = nums[i]
- }
- }
-
- return false
-};
-```
-
-## C#
-
-```csharp
-public class Solution {
- public bool IncreasingTriplet(int[] nums) {
- int first = nums[0];
- int second = int.MaxValue;
-
- for (int i = 1; i < nums.Length; i++) {
- if (nums[i] > second) {
- return true;
- }
-
- // Here, nums[i] <= second
- if (nums[i] > first) {
- second = nums[i];
- } else {
- first = nums[i];
- }
- }
-
- return false;
- }
-}
-```
-
-## Go
-
-```go
-func increasingTriplet(nums []int) bool {
- first := nums[0]
- second := math.MaxInt32
-
- for _, num := range nums[1:] {
- if num > second {
- return true
- }
-
- // Here, num <= second
- if num > first {
- second = num
- } else {
- first = num
- }
- }
-
- return false
-}
-```
-
-## Ruby
-
-```ruby
-# @param {Integer[]} nums
-# @return {Boolean}
-def increasing_triplet(nums)
- first = nums[0]
- second = Float::INFINITY
-
- nums[1..].each do |num|
- if num > second
- return true
- end
-
- # Here, num <= second
- if num > first
- second = num
- else
- first = num
- end
- end
-
- false
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [334. Increasing Triplet Subsequence - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/334-increasing-triplet-subsequence) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/337-house-robber-iii.md b/en/1-1000/337-house-robber-iii.md
deleted file mode 100644
index c82a91e..0000000
--- a/en/1-1000/337-house-robber-iii.md
+++ /dev/null
@@ -1,244 +0,0 @@
-# 337. House Robber III
-LeetCode link: [337. House Robber III](https://leetcode.com/problems/house-robber-iii/)
-
-## LeetCode problem description
-The thief has found himself a new place for his thievery again. There is only one entrance to this area, called `root`.
-
-Besides the `root`, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. **It will automatically contact the police if two directly-linked houses were broken into on the same night**.
-
-Given the `root` of the binary tree, return the **maximum amount of money** the thief can rob **without alerting the police**.
-```
-------------------------------------------------------------------------
-[Example 1]
-
-Input: root = [3,2,3,null,3,null,1]
-Output: 7
-Explanation: Maximum amount of money the thief can rob = 3 + 3 + 1 = 7.
-------------------------------------------------------------------------
-[Example 2]
-
-Input: root = [3,4,5,1,3,null,1]
-Output: 9
-Explanation: Maximum amount of money the thief can rob = 4 + 5 = 9.
-------------------------------------------------------------------------
-[Constraints]
-
-The number of nodes in the tree is in the range [1, 10000].
-0 <= Node.val <= 10000
-------------------------------------------------------------------------
-```
-
-## Thoughts
-This problem can be solved using **Dynamic programming**.
-
-Detailed solutions will be given later, and now only the best practices in 3-7 languages are given.
-
-### Complexity
-* Time: `O(n)`.
-* Space: `O(n)`.
-
-## Python
-### Solution 1: Easier to understand
-```python
-class Solution:
- def __init__(self):
- self.node_to_money = defaultdict(int)
-
- # Uncomment the next line, you can solve it without using `self.node_to_money` dict.
- # @cache
- def rob(self, node: Optional[TreeNode]) -> int:
- if node is None:
- return 0
-
- if node in self.node_to_money:
- return self.node_to_money[node]
-
- money_exclude_node = self.rob(node.left) + self.rob(node.right)
-
- money_include_node = node.val
- if node.left:
- money_include_node += self.rob(node.left.left) + self.rob(node.left.right)
- if node.right:
- money_include_node += self.rob(node.right.left) + self.rob(node.right.right)
-
- self.node_to_money[node] = max(money_exclude_node, money_include_node)
-
- return self.node_to_money[node]
-```
-
-### Solution 2: Most concise
-```python
-class Solution:
- def rob(self, root: Optional[TreeNode]) -> int:
- return max(self.rob_tree(root))
-
- def rob_tree(self, node):
- if node is None:
- return 0, 0
-
- left_pair = self.rob_tree(node.left)
- right_pair = self.rob_tree(node.right)
-
- return max(left_pair) + max(right_pair), node.val + left_pair[0] + right_pair[0]
-```
-
-## C++
-```cpp
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Java
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## C#
-```c#
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## JavaScript
-### Solution 1: Easier to understand
-```javascript
-const nodeToMoney = new Map()
-
-var rob = function (root) {
- nodeToMoney.clear()
-
- return robTree(root)
-};
-
-
-function robTree(node) {
- if (node == null) {
- return 0
- }
-
- if (nodeToMoney.has(node)) {
- return nodeToMoney.get(node)
- }
-
- const moneyExcludeNode = robTree(node.left) + robTree(node.right)
-
- let moneyIncludeNode = node.val
- if (node.left) {
- moneyIncludeNode += robTree(node.left.left) + robTree(node.left.right)
- }
- if (node.right) {
- moneyIncludeNode += robTree(node.right.left) + robTree(node.right.right)
- }
-
- nodeToMoney.set(node, Math.max(moneyExcludeNode, moneyIncludeNode))
-
- return nodeToMoney.get(node)
-}
-```
-
-### Solution 2: Most concise
-```javascript
-var rob = function (root) {
- return Math.max(...robTree(root))
-};
-
-function robTree(node) {
- if (node == null) {
- return [0, 0]
- }
-
- const leftPair = robTree(node.left)
- const rightPair = robTree(node.right)
-
- return [
- Math.max(...leftPair) + Math.max(...rightPair),
- node.val + leftPair[0] + rightPair[0]
- ]
-}
-```
-
-## Go
-### Solution 1: Easier to understand
-```go
-/**
- * Definition for a binary tree node.
- * type TreeNode struct {
- * Val int
- * Left *TreeNode
- * Right *TreeNode
- * }
- */
-func rob(root *TreeNode) int {
- nodeToMoney := map[*TreeNode]int{}
-
- var robTree func (*TreeNode) int
-
- robTree = func (node *TreeNode) int {
- if node == nil {
- return 0
- }
-
- if money, ok := nodeToMoney[node]; ok {
- return money
- }
-
- moneyExcludeNode := robTree(node.Left) + robTree(node.Right)
-
- moneyIncludeNode := node.Val
- if node.Left != nil {
- moneyIncludeNode += robTree(node.Left.Left) + robTree(node.Left.Right)
- }
- if node.Right != nil {
- moneyIncludeNode += robTree(node.Right.Left) + robTree(node.Right.Right)
- }
-
- nodeToMoney[node] = max(moneyExcludeNode, moneyIncludeNode)
-
- return nodeToMoney[node]
- }
-
- return robTree(root)
-}
-```
-
-### Solution 2: Most concise
-```go
-/**
- * Definition for a binary tree node.
- * type TreeNode struct {
- * Val int
- * Left *TreeNode
- * Right *TreeNode
- * }
- */
-func rob(root *TreeNode) int {
- return slices.Max(robTree(root))
-}
-
-func robTree(node *TreeNode) []int {
- if node == nil {
- return []int{0, 0}
- }
-
- leftPair := robTree(node.Left)
- rightPair := robTree(node.Right)
-
- return []int{
- slices.Max(leftPair) + slices.Max(rightPair),
- node.Val + leftPair[0] + rightPair[0],
- }
-}
-```
-
-## Ruby
-```ruby
-# Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Rust
-```rust
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Other languages
-```
-// Welcome to create a PR to complete the code of this language, thanks!
-```
diff --git a/en/1-1000/344-reverse-string.md b/en/1-1000/344-reverse-string.md
deleted file mode 100644
index 409ee99..0000000
--- a/en/1-1000/344-reverse-string.md
+++ /dev/null
@@ -1,248 +0,0 @@
-# 344. Reverse String - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [344. Reverse String - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/344-reverse-string) for a better experience!
-
-LeetCode link: [344. Reverse String](https://leetcode.com/problems/reverse-string), difficulty: **Easy**.
-
-## LeetCode description of "344. Reverse String"
-
-Write a function that reverses a string. The input string is given as an array of characters `s`.
-
-You must do this by modifying the input array [in-place](https://en.wikipedia.org/wiki/In-place_algorithm) with `O(1)` extra memory.
-
-### [Example 1]
-
-**Input**: `s = ["h","e","l","l","o"]`
-
-**Output**: `["o","l","l","e","h"]`
-
-### [Example 2]
-
-**Input**: `s = ["H","a","n","n","a","h"]`
-
-**Output**: `["h","a","n","n","a","H"]`
-
-### [Constraints]
-
-- `1 <= s.length <= 10^5`
-- `s[i]` is a [printable ascii character](https://en.wikipedia.org/wiki/ASCII#Printable_characters).
-
-### [Hints]
-
-
- Hint 1
- The entire logic for reversing a string is based on using the opposite directional two-pointer approach!
-
-
-
-
-## Intuition
-
-1. This problem can be solved in one line of code using the built-in `sort()` method of the programming language. If this question is asked in an interview, the questioner should be testing how to do it without the built-in method.
-2. Use **two pointers** with **opposite directions**, initially one pointer points to the index `0` and the other pointer points to the index `s.length - 1`.
-3. Traverse the elements of the array, and the loop condition is `while (left < right)`. In the loop body, `left += 1`, `right -= 1`.
-4. In the loop body, swap the two values.
-5. The above is the template for `two pointers` in `opposite directions`.
-
-## Step-by-Step Solution
-
-1. Use two pointers with **opposite directions**, initially one pointer points to the index `0` and the other pointer points to the index `s.length - 1`.
-
- ```ruby
- left = 0
- right = s.length - 1
- ```
-
-2. Traverse the elements of the array, and the loop condition is `while (left < right)`. In the loop body, `left += 1`, `right -= 1`.
-
- ```ruby
- left = 0
- right = s.length - 1
-
- while left < right # 1
- left += 1 # 2
- right -= 1 # 3
- end
- ```
-
-3. In the loop body, swap the two values.
-
- ```ruby
- left = 0
- right = s.length - 1
-
- while left < right
- s[left], s[right] = s[right], s[left] # 1
-
- left += 1
- right -= 1
- end
- ```
-
-## Complexity
-
-- Time complexity: `O(N)`.
-- Space complexity: `O(1)`.
-
-## Java
-
-```java
-class Solution {
- public void reverseString(char[] s) {
- var left = 0;
- var right = s.length - 1;
-
- while (left < right) {
- var leftValue = s[left];
- s[left] = s[right];
- s[right] = leftValue;
-
- left++;
- right--;
- }
- }
-}
-```
-
-## Python
-
-```python
-class Solution:
- def reverseString(self, s: List[str]) -> None:
- left = 0
- right = len(s) - 1
-
- while left < right:
- s[left], s[right] = s[right], s[left]
- left += 1
- right -= 1
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- void reverseString(vector& s) {
- auto left = 0;
- auto right = s.size() - 1;
-
- while (left < right) {
- swap(s[left], s[right]);
-
- left++;
- right--;
- }
- }
-};
-```
-
-## JavaScript
-
-```javascript
-var reverseString = function (s) {
- let left = 0
- let right = s.length - 1
-
- while (left < right) {
- [s[left], s[right]] = [s[right], s[left]]
-
- left++
- right--
- }
-};
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- public void ReverseString(char[] s)
- {
- int left = 0;
- int right = s.Length - 1;
-
- while (left < right)
- {
- (s[left], s[right]) = (s[right], s[left]);
-
- left++;
- right--;
- }
- }
-}
-```
-
-## Go
-
-```go
-func reverseString(s []byte) {
- left := 0
- right := len(s) - 1
-
- for left < right {
- s[left], s[right] = s[right], s[left]
-
- left++
- right--
- }
-}
-```
-
-## Ruby
-
-```ruby
-def reverse_string(s)
- left = 0
- right = s.size - 1
-
- while left < right
- s[left], s[right] = s[right], s[left]
-
- left += 1
- right -= 1
- end
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [344. Reverse String - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/344-reverse-string) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/345-reverse-vowels-of-a-string.md b/en/1-1000/345-reverse-vowels-of-a-string.md
deleted file mode 100644
index d96fb84..0000000
--- a/en/1-1000/345-reverse-vowels-of-a-string.md
+++ /dev/null
@@ -1,330 +0,0 @@
-# 345. Reverse Vowels of a String - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [345. Reverse Vowels of a String - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/345-reverse-vowels-of-a-string) for a better experience!
-
-LeetCode link: [345. Reverse Vowels of a String](https://leetcode.com/problems/reverse-vowels-of-a-string), difficulty: **Easy**.
-
-## LeetCode description of "345. Reverse Vowels of a String"
-
-Given a string `s`, reverse only all the vowels in the string and return it.
-
-The vowels are `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`, and they can appear in both lower and upper cases, more than once.
-
-### [Example 1]
-
-**Input**: `s = "IceCreAm"`
-
-**Output**: `"AceCreIm"`
-
-**Explanation**:
-
-The vowels in s are ['I', 'e', 'e', 'A']. On reversing the vowels, s becomes "AceCreIm".
-
-
-### [Example 2]
-
-**Input**: `"leetcode"`
-
-**Output**: `"leotcede"`
-
-### [Constraints]
-
-- `1 <= s.length <= 3 * 10^5`
-- `s` consist of **printable ASCII** characters.
-
-## Intuition
-
-Use two pointers to swap vowels in the string. The left pointer finds vowels from the start, the right pointer finds vowels from the end, and they swap until the pointers meet.
-
-## Pattern of "left & right pointers"
-
-The code framework is as follows:
-
-```java
-int r = target.length() - 1;
-
-for (int l = 0; l < target.length(); l++) { // Important
- // ...
- if (l >= r) {
- break;
- }
-
- // ...
- r--;
-}
-```
-
-## Step-by-Step Solution
-
-1. Initialize a set of vowels
-2. For some languages, convert the string to a character array (since strings are immutable)
-3. Left pointer `l` starts at `0`, right pointer `r` starts at the end
-4. Loop processing:
- - Move `l` right until a vowel is found
- - Move `r` left until a vowel is found
- - Swap the two vowels when `l < r`
-5. Return the processed string
-
-## Complexity
-
-> Space complexity is O(N) if converting to a character array
-
-- Time complexity: `O(N)`.
-- Space complexity: `O(1) or O(N)`.
-
-## Python
-
-```python
-class Solution:
- def reverseVowels(self, s: str) -> str:
- vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
- s = list(s)
- r = len(s) - 1
-
- for l in range(len(s)): # Important
- if s[l] not in vowels:
- continue
-
- while r > 0 and s[r] not in vowels:
- r -= 1
-
- if l >= r:
- break
-
- s[l], s[r] = s[r], s[l]
- r -= 1
-
- return ''.join(s)
-```
-
-## Java
-
-```java
-class Solution {
- public String reverseVowels(String s) {
- var vowels = new HashSet<>(Arrays.asList('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'));
- var chars = s.toCharArray();
- int r = chars.length - 1;
-
- for (int l = 0; l < chars.length; l++) { // important
- if (!vowels.contains(chars[l])) {
- continue;
- }
-
- while (r > 0 && !vowels.contains(chars[r])) {
- r--;
- }
-
- if (l >= r) {
- break;
- }
-
- // Swap the vowels
- char temp = chars[l];
- chars[l] = chars[r];
- chars[r] = temp;
- r--;
- }
-
- return new String(chars);
- }
-}
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- string reverseVowels(string s) {
- unordered_set vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'};
- int r = s.size() - 1;
-
- for (int l = 0; l < s.size(); l++) { // important
- if (!vowels.contains(s[l])) {
- continue;
- }
-
- while (r > 0 && !vowels.contains(s[r])) {
- r--;
- }
-
- if (l >= r) {
- break;
- }
-
- swap(s[l], s[r]);
- r--;
- }
-
- return s;
- }
-};
-```
-
-## JavaScript
-
-```javascript
-var reverseVowels = function (s) {
- const vowels = new Set(['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'])
- const chars = s.split('')
- let r = chars.length - 1
-
- for (let l = 0; l < chars.length; l++) { // important
- if (!vowels.has(chars[l])) {
- continue
- }
-
- while (r > 0 && !vowels.has(chars[r])) {
- r--
- }
-
- if (l >= r) {
- break
- }
-
- [chars[l], chars[r]] = [chars[r], chars[l]]
- r--
- }
-
- return chars.join('')
-};
-```
-
-## Ruby
-
-```ruby
-def reverse_vowels(s)
- vowels = Set.new(['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'])
- r = s.size - 1
-
- (0...s.size).each do |l|
- unless vowels.include?(s[l])
- next
- end
-
- while r > 0 && !vowels.include?(s[r])
- r -= 1
- end
-
- if l >= r
- break
- end
-
- s[l], s[r] = s[r], s[l]
- r -= 1
- end
-
- s
-end
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- public string ReverseVowels(string s)
- {
- var vowels = new HashSet {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'};
- var chars = s.ToCharArray();
- int r = chars.Length - 1;
- // important
- for (int l = 0; l < chars.Length; l++)
- {
- if (!vowels.Contains(chars[l]))
- {
- continue;
- }
-
- while (r > 0 && !vowels.Contains(chars[r]))
- {
- r--;
- }
-
- if (l >= r)
- {
- break;
- }
-
- (chars[l], chars[r]) = (chars[r], chars[l]);
- r--;
- }
-
- return new string(chars);
- }
-}
-```
-
-## Go
-
-```go
-func reverseVowels(s string) string {
- vowels := map[byte]bool{
- 'a': true, 'e': true, 'i': true, 'o': true, 'u': true,
- 'A': true, 'E': true, 'I': true, 'O': true, 'U': true,
- }
- chars := []byte(s)
- r := len(chars) - 1
-
- for l := 0; l < len(chars); l++ { // important
- if !vowels[chars[l]] {
- continue
- }
-
- for r > 0 && !vowels[chars[r]] {
- r--
- }
-
- if l >= r {
- break
- }
-
- chars[l], chars[r] = chars[r], chars[l]
- r--
- }
-
- return string(chars)
-}
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [345. Reverse Vowels of a String - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/345-reverse-vowels-of-a-string) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/349-intersection-of-two-arrays.md b/en/1-1000/349-intersection-of-two-arrays.md
deleted file mode 100644
index 313c395..0000000
--- a/en/1-1000/349-intersection-of-two-arrays.md
+++ /dev/null
@@ -1,223 +0,0 @@
-# 349. Intersection of Two Arrays - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [349. Intersection of Two Arrays - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/349-intersection-of-two-arrays) for a better experience!
-
-LeetCode link: [349. Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays), difficulty: **Easy**.
-
-## LeetCode description of "349. Intersection of Two Arrays"
-
-Given two integer arrays `nums1` and `nums2`, return _an array of their **intersection**_.
-Each element in the result must be **unique** and you may return the result in **any order**.
-
-> Array Intersection: The intersection of two arrays is defined as the set of elements that are present in both arrays.
-
-
-### [Example 1]
-
-**Input**: `nums1 = [1,2,2,1], nums2 = [2,2]`
-
-**Output**: `[2]`
-
-### [Example 2]
-
-**Input**: `nums1 = [4,9,5], nums2 = [9,4,9,8,4]`
-
-**Output**: `[9,4]`
-
-**Explanation**: `[4,9] is also accepted.`
-
-### [Constraints]
-
-- `1 <= nums1.length, nums2.length <= 1000`
-- `0 <= nums1[i], nums2[i] <= 1000`
-
-## Intuition
-
-1. Convert one of the arrays to a `set`. The elements are unique in a `set`.
-2. When traversing the other array, if an element is found to already exist in the `set`, it means that the element belongs to the intersection, and the element should be added to the `results`.
-3. The `results` is also of `set` type because duplicate removal is required.
-
-## Complexity
-
-- Time complexity: `O(N)`.
-- Space complexity: `O(N)`.
-
-## Java
-
-```java
-class Solution {
- public int[] intersection(int[] nums1, int[] nums2) {
- var results = new HashSet();
- var num1Set = new HashSet();
-
- for (var num : nums1) {
- num1Set.add(num);
- }
-
- for (var num : nums2) {
- if (num1Set.contains(num)) {
- results.add(num);
- }
- }
-
- return results.stream().mapToInt(num -> num).toArray();
- }
-}
-```
-
-## Python
-
-```python
-class Solution:
- def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
- set_of_nums1 = set(nums1)
- results = set()
-
- for num in nums2:
- if num in set_of_nums1:
- results.add(num)
-
- return list(results)
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- vector intersection(vector& nums1, vector& nums2) {
- unordered_set results;
- unordered_set set_of_nums1(nums1.begin(), nums1.end());
-
- for (auto num : nums2) {
- if (set_of_nums1.contains(num)) {
- results.insert(num);
- }
- }
-
- return vector(results.begin(), results.end());
- }
-};
-```
-
-## JavaScript
-
-```javascript
-var intersection = function (nums1, nums2) {
- let results = new Set()
- let num1Set = new Set(nums1)
-
- for (const num of nums2) {
- if (num1Set.has(num)) {
- results.add(num)
- }
- }
-
- return Array.from(results)
-};
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- public int[] Intersection(int[] nums1, int[] nums2)
- {
- var results = new HashSet();
- var num1Set = new HashSet();
-
- foreach (int num in nums1)
- num1Set.Add(num);
-
- foreach (int num in nums2)
- {
- if (num1Set.Contains(num))
- {
- results.Add(num);
- }
- }
-
- return results.ToArray();
- }
-}
-```
-
-## Go
-
-```go
-func intersection(nums1 []int, nums2 []int) []int {
- results := map[int]bool{}
- num1Set := map[int]bool{}
-
- for _, num := range nums1 {
- num1Set[num] = true
- }
-
- for _, num := range nums2 {
- if _, ok := num1Set[num]; ok {
- results[num] = true
- }
- }
-
- return slices.Collect(maps.Keys(results))
-}
-```
-
-## Ruby
-
-```ruby
-def intersection(nums1, nums2)
- nums1_set = Set.new(nums1)
- results = Set.new
-
- nums2.each do |num|
- if nums1_set.include?(num)
- results << num
- end
- end
-
- results.to_a
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [349. Intersection of Two Arrays - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/349-intersection-of-two-arrays) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/377-combination-sum-iv.md b/en/1-1000/377-combination-sum-iv.md
deleted file mode 100644
index 9bd1a16..0000000
--- a/en/1-1000/377-combination-sum-iv.md
+++ /dev/null
@@ -1,192 +0,0 @@
-# 377. Combination Sum IV
-LeetCode link: [377. Combination Sum IV](https://leetcode.com/problems/combination-sum-iv/)
-
-## LeetCode problem description
-> Given an array of **distinct** integers `nums` and a target integer `target`, return the number of possible combinations that add up to `target`.
-
-The test cases are generated so that the answer can fit in a 32-bit integer.
-
-```
-Example 1:
-
-Input: nums = [1,2,3], target = 4
-Output: 7
-
-Explanation:
-The possible combination ways are:
-(1, 1, 1, 1)
-(1, 1, 2)
-(1, 2, 1)
-(1, 3)
-(2, 1, 1)
-(2, 2)
-(3, 1)
-Note that different sequences are counted as different combinations.
-------------------------------------------------------------------------
-
-Example 2:
-
-Input: nums = [9], target = 3
-Output: 0
-
-------------------------------------------------------------------------
-
-Constraints:
-
-1 <= nums.length <= 200
-1 <= nums[i] <= 1000
-All the elements of 'nums' are 'unique'.
-1 <= target <= 1000
-```
-
-## Thoughts
-This is `Unbounded Knapsack Problem` A, and it also requires us to consider the sequences.
-
-Detailed solutions will be given later, and now only the best practices in 7 languages are given.
-
-### Complexity
-* Time: `O(n * m)`.
-* Space: `O(n)`.
-
-## C#
-```c#
-public class Solution
-{
- public int CombinationSum4(int[] nums, int target)
- {
- var dp = new int[target + 1];
- dp[0] = 1;
-
- for (var i = 1; i < dp.Length; i++)
- {
- foreach (var num in nums)
- {
- if (i >= num)
- {
- dp[i] += dp[i - num];
- }
- }
- }
-
- return dp.Last();
- }
-}
-```
-
-## Python
-```python
-class Solution:
- def combinationSum4(self, nums: List[int], target: int) -> int:
- dp = [0] * (target + 1)
- dp[0] = 1
-
- for i in range(1, len(dp)):
- for num in nums:
- if i >= num:
- dp[i] += dp[i - num]
-
- return dp[-1]
-```
-
-## C++
-```cpp
-class Solution {
-public:
- int combinationSum4(vector& nums, int target) {
- vector dp(target + 1, 0);
- dp[0] = 1;
-
- for (auto i = 1; i < dp.size(); i++) {
- for (auto num : nums) {
- if (i >= num) {
- dp[i] += dp[i - num];
- }
- }
- }
-
- return dp.back();
- }
-};
-```
-
-## Java
-```java
-class Solution {
- public int combinationSum4(int[] nums, int target) {
- var dp = new int[target + 1];
- dp[0] = 1;
-
- for (var i = 1; i < dp.length; i++) {
- for (var num : nums) {
- if (i >= num) {
- dp[i] += dp[i - num];
- }
- }
- }
-
- return dp[target];
- }
-}
-```
-
-## JavaScript
-```javascript
-var combinationSum4 = function (nums, target) {
- const dp = Array(target + 1).fill(0)
- dp[0] = 1
-
- for (let i = 1; i < dp.length; i++) {
- for (const num of nums) {
- if (i >= num) {
- dp[i] += dp[i - num]
- }
- }
- }
-
- return dp.at(-1)
-};
-```
-
-## Go
-```go
-func combinationSum4(nums []int, target int) int {
- dp := make([]int, target + 1)
- dp[0] = 1
-
- for i := 1; i < len(dp); i++ {
- for _, num := range nums {
- if i >= num {
- dp[i] += dp[i - num]
- }
- }
- }
-
- return dp[target]
-}
-```
-
-## Ruby
-```ruby
-def combination_sum4(nums, target)
- dp = Array.new(target + 1, 0)
- dp[0] = 1
-
- (1...dp.size).each do |i|
- nums.each do |num|
- dp[i] += dp[i - num] if i >= num
- end
- end
-
- return dp[-1]
-end
-```
-
-## Rust
-```rust
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Other languages
-```
-// Welcome to create a PR to complete the code of this language, thanks!
-```
diff --git a/en/1-1000/383-ransom-note.md b/en/1-1000/383-ransom-note.md
deleted file mode 100644
index 95e7320..0000000
--- a/en/1-1000/383-ransom-note.md
+++ /dev/null
@@ -1,280 +0,0 @@
-# 383. Ransom Note - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [383. Ransom Note - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/383-ransom-note) for a better experience!
-
-LeetCode link: [383. Ransom Note](https://leetcode.com/problems/ransom-note), difficulty: **Easy**.
-
-## LeetCode description of "383. Ransom Note"
-
-Given two strings `ransomNote` and `magazine`, return `true` if `ransomNote` can be constructed by using the letters from `magazine` and `false` otherwise.
-
-Each letter in `magazine` can only be used once in `ransomNote`.
-
-### [Example 1]
-
-**Input**: `ransomNote = "a", magazine = "b"`
-
-**Output**: `false`
-
-### [Example 2]
-
-**Input**: `ransomNote = "aa", magazine = "ab"`
-
-**Output**: `false`
-
-### [Example 3]
-
-**Input**: `ransomNote = "aa", magazine = "aab"`
-
-**Output**: `true`
-
-### [Constraints]
-
-- `1 <= ransomNote.length, magazine.length <= 10^5`
-- `ransomNote` and `magazine` consist of lowercase English letters.
-
-## Intuition
-
-1. This question is equivalent to asking whether `magazine` can contain all the characters in `ransomNote`.
-
-2. First count `magazine` to get the number of words corresponding to each character, and store the result in `Map`. Each time is an addition one operation.
-
-3. What to do next?
-
- Click to view the answer
Traverses `ransomNote` and subtracts one from the number corresponding to the current character (reverse operation). If the number of a character is less than 0, return `false`.
-
-## Step-by-Step Solution
-
-1. First count the characters in `magazine`, and store the results in `Map`.
-
- ```javascript
- charToCount = new Map()
-
- for (character in magazine) {
- charToCount[character] += 1
- }
- ```
-
-2. Then, traverse `ransomNote` and perform reverse operations on the data in `Map`. If the count of a character is less than 0, return `false`.
-
- ```javascript
- charToCount = new Map()
-
- for (character in magazine) {
- charToCount[character] += 1
- }
-
- for (character in ransomNote) {
- charToCount[character] -= 1
-
- if (charToCount[character] < 0) {
- return false
- }
- }
-
- return true
- ```
-
-## Complexity
-
-- Time complexity: `O(N)`.
-- Space complexity: `O(N)`.
-
-## Java
-
-```java
-class Solution {
- public boolean canConstruct(String ransomNote, String magazine) {
- var charToCount = new HashMap();
-
- for (var character : magazine.toCharArray()) {
- charToCount.put(character, charToCount.getOrDefault(character, 0) + 1);
- }
-
- for (var character : ransomNote.toCharArray()) {
- charToCount.put(character, charToCount.getOrDefault(character, 0) - 1);
-
- if (charToCount.get(character) < 0) {
- return false;
- }
- }
-
- return true;
- }
-}
-```
-
-## Python
-
-```python
-# from collections import defaultdict
-
-class Solution:
- def canConstruct(self, ransomNote: str, magazine: str) -> bool:
- char_to_count = defaultdict(int)
-
- for char in magazine:
- char_to_count[char] += 1
-
- for char in ransomNote:
- char_to_count[char] -= 1
-
- if char_to_count[char] < 0:
- return False
-
- return True
-```
-
-## JavaScript
-
-```javascript
-var canConstruct = function (ransomNote, magazine) {
- const charToCount = new Map()
-
- for (const character of magazine) {
- charToCount.set(character, (charToCount.get(character) || 0) + 1)
- }
-
- for (const character of ransomNote) {
- charToCount.set(character, (charToCount.get(character) || 0) - 1)
-
- if (charToCount.get(character) < 0) {
- return false
- }
- }
-
- return true
-};
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- public bool CanConstruct(string ransomNote, string magazine)
- {
- var charToCount = new Dictionary();
-
- foreach (char character in magazine)
- charToCount[character] = charToCount.GetValueOrDefault(character, 0) + 1;
-
- foreach (char character in ransomNote)
- {
- charToCount[character] = charToCount.GetValueOrDefault(character, 0) - 1;
-
- if (charToCount[character] < 0)
- {
- return false;
- }
- }
-
- return true;
- }
-}
-```
-
-## Ruby
-
-```ruby
-def can_construct(ransom_note, magazine)
- char_to_count = Hash.new(0)
-
- magazine.each_char { |c| char_to_count[c] += 1 }
-
- ransom_note.each_char do |c|
- char_to_count[c] -= 1
- return false if char_to_count[c] < 0
- end
-
- true
-end
-```
-
-## Go
-
-```go
-func canConstruct(ransomNote string, magazine string) bool {
- charToCount := make(map[rune]int)
-
- for _, char := range magazine {
- charToCount[char]++
- }
-
- for _, char := range ransomNote {
- charToCount[char]--
-
- if charToCount[char] < 0 {
- return false
- }
- }
-
- return true
-}
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- bool canConstruct(string ransomNote, string magazine) {
- unordered_map char_to_count;
-
- for (char character : magazine) {
- char_to_count[character]++;
- }
-
- for (char character : ransomNote) {
- char_to_count[character]--;
-
- if (char_to_count[character] < 0) {
- return false;
- }
- }
-
- return true;
- }
-};
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [383. Ransom Note - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/383-ransom-note) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/392-is-subsequence.md b/en/1-1000/392-is-subsequence.md
deleted file mode 100644
index 169e87d..0000000
--- a/en/1-1000/392-is-subsequence.md
+++ /dev/null
@@ -1,543 +0,0 @@
-# 392. Is Subsequence - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [392. Is Subsequence - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/392-is-subsequence) for a better experience!
-
-LeetCode link: [392. Is Subsequence](https://leetcode.com/problems/is-subsequence), difficulty: **Medium**.
-
-## LeetCode description of "392. Is Subsequence"
-
-Given two strings `s` and `t`, return `true` if `s` is a **subsequence** of `t`, or `false` otherwise.
-
-A **subsequence** of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., `"ace"` is a subsequence of `"abcde"` while `"aec"` is not).
-
-
-**Follow up**: Suppose there are lots of incoming `s`, say `s1, s2, ..., sk` where `k >= 10^9`, and you want to check one by one to see if `t` has its subsequence. In this scenario, how would you change your code?
-
-### [Example 1]
-
-**Input**: `s = "abc", t = "ahbgdc"`
-
-**Output**: `true`
-
-### [Example 2]
-
-**Input**: `s = "axc", t = "ahbgdc"`
-
-**Output**: `false`
-
-### [Constraints]
-
-- `0 <= s.length <= 100`
-- `0 <= t.length <= 10^4`
-- `s` and `t` consist only of lowercase English letters.
-
-## Intuition 1
-
-- Define two pointers, initially pointing to the heads of two strings respectively, and reference characters with `t[i]` and `s[j]`.
-- During the traversal of `t`, `i` is automatically incremented by 1, and if `t[i] == s[j]`, then `j += 1`.
-- If `j >= s.length`, return `true`. If `t` is traversed and still not returned in advance, return `false`.
-
-## Complexity
-
-- Time complexity: `O(N)`.
-- Space complexity: `O(1)`.
-
-## Python
-
-```python
-class Solution:
- def isSubsequence(self, s: str, t: str) -> bool:
- if s == "":
- return True
-
- s_index = 0
-
- for i in range(len(t)):
- if t[i] == s[s_index]:
- s_index += 1
-
- if s_index >= len(s):
- return True
-
- return False
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- bool isSubsequence(string s, string t) {
- if (s.empty()) {
- return true;
- }
-
- int s_index = 0;
-
- for (int i = 0; i < t.length(); i++) {
- if (t[i] == s[s_index]) {
- s_index++;
-
- if (s_index >= s.length()) {
- return true;
- }
- }
- }
-
- return false;
- }
-};
-```
-
-## Java
-
-```java
-class Solution {
- public boolean isSubsequence(String s, String t) {
- if (s.isEmpty()) {
- return true;
- }
-
- int sIndex = 0;
-
- for (int i = 0; i < t.length(); i++) {
- if (t.charAt(i) == s.charAt(sIndex)) {
- sIndex++;
-
- if (sIndex >= s.length()) {
- return true;
- }
- }
- }
-
- return false;
- }
-}
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- public bool IsSubsequence(string s, string t)
- {
- if (string.IsNullOrEmpty(s))
- {
- return true;
- }
-
- int sIndex = 0;
-
- for (int i = 0; i < t.Length; i++)
- {
- if (t[i] == s[sIndex])
- {
- sIndex++;
-
- if (sIndex >= s.Length)
- {
- return true;
- }
- }
- }
-
- return false;
- }
-}
-```
-
-## Go
-
-```go
-func isSubsequence(s string, t string) bool {
- if len(s) == 0 {
- return true
- }
-
- sIndex := 0
-
- for i := 0; i < len(t); i++ {
- if t[i] == s[sIndex] {
- sIndex++
-
- if sIndex >= len(s) {
- return true
- }
- }
- }
-
- return false
-}
-```
-
-## JavaScript
-
-```javascript
-/**
- * @param {string} s
- * @param {string} t
- * @return {boolean}
- */
-var isSubsequence = function(s, t) {
- if (s.length === 0) {
- return true;
- }
-
- let sIndex = 0;
-
- for (let i = 0; i < t.length; i++) {
- if (t[i] === s[sIndex]) {
- sIndex++;
-
- if (sIndex >= s.length) {
- return true;
- }
- }
- }
-
- return false;
-};
-```
-
-## Ruby
-
-```ruby
-# @param {String} s
-# @param {String} t
-# @return {Boolean}
-def is_subsequence(s, t)
- return true if s.empty?
-
- s_index = 0
-
- t.each_char.with_index do |char, i|
- if char == s[s_index]
- s_index += 1
- return true if s_index >= s.length
- end
- end
-
- false
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Intuition 2
-
-- `Solution 1` is essentially a "dynamic programming" algorithm implemented with `rolling variables`. It is easy to understand, and the space complexity is reduced to `O(1)`.
-- But now, not only do we not reduce the dimension, but we also increase the dimension. It will be more difficult to understand and implement. So why do this thankless task?
- Click to view the answer
Because it can handle a more complex scenario (e.g. [583. Delete Operation for Two Strings](583-delete-operation-for-two-strings.md)) that is common in dynamic programming.
-- In this question, can we use a `one-dimensional rolling array` to implement the "dynamic programming" algorithm?
- Click to view the answer
Of course, but considering that for this problem a `one-dimensional rolling array` is not as easy to understand as a `two-dimensional array`, and the implementation process is also prone to errors, so here I didn't give the relevant code implementation. If you are interested, you can try it.
-- The **compare two strings** question is about dealing with "two swappable arrays". After doing similar questions many times, we will form the intuition of using `two-dimensional arrays` for dynamic programming.
-
-## Pattern of "Dynamic Programming"
-
-"Dynamic Programming" requires the use of the `dp` array to store the results. The value of `dp[i][j]` can be converted from its previous (or multiple) values through a formula. Therefore, the value of `dp[i][j]` is derived step by step, and it is related to the previous `dp` record value.
-
-#### "Dynamic programming" is divided into five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
-2. Initialize the value of the array `dp`.
-3. Fill in the `dp` grid data **in order** according to an example.
-4. Based on the `dp` grid data, derive the **recursive formula**.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
-
-#### Detailed description of these five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
- - First determine whether `dp` is a one-dimensional array or a two-dimensional array. A `one-dimensional rolling array` means that the values of the array are overwritten at each iteration. Most of the time, using `one-dimensional rolling array` instead of `two-dimensional array` can simplify the code; but for some problems, such as operating "two swappable arrays", for the sake of ease of understanding, it is better to use `two-dimensional array`.
- - Try to use the meaning of the `return value` required by the problem as the meaning of `dp[i]` (one-dimensional) or `dp[i][j]` (two-dimensional). It works about 60% of the time. If it doesn't work, try other meanings.
- - Try to save more information in the design. Repeated information only needs to be saved once in a `dp[i]`.
- - Use simplified meanings. If the problem can be solved with `boolean value`, don't use `numeric value`.
-2. Initialize the value of the array `dp`. The value of `dp` involves two levels:
- 1. The length of `dp`. Usually: `condition array length plus 1` or `condition array length`.
- 2. The value of `dp[i]` or `dp[i][j]`. `dp[0]` or `dp[0][0]` sometimes requires special treatment.
-3. Fill in the `dp` grid data **in order** according to an example.
- - The "recursive formula" is the core of the "dynamic programming" algorithm. But the "recursive formula" is obscure. If you want to get it, you need to make a table and use data to inspire yourself.
- - If the original example is not good enough, you need to redesign one yourself.
- - According to the example, fill in the `dp` grid data "in order", which is very important because it determines the traversal order of the code.
- - Most of the time, from left to right, from top to bottom. But sometimes it is necessary to traverse from right to left, from bottom to top, from the middle to the right (or left), such as the "palindrome" problems. Sometimes, it is necessary to traverse a line twice, first forward and then backward.
- - When the order is determined correctly, the starting point is determined. Starting from the starting point, fill in the `dp` grid data "in order". This order is also the order in which the program processes.
- - In this process, you will get inspiration to write a "recursive formula". If you can already derive the formula, you do not need to complete the grid.
-4. Based on the `dp` grid data, derive the **recursive formula**.
- - There are three special positions to pay attention to: `dp[i - 1][j - 1]`, `dp[i - 1][j]` and `dp[i][j - 1]`, the current `dp[i][j]` often depends on them.
- - When operating "two swappable arrays", due to symmetry, we may need to use `dp[i - 1][j]` and `dp[i][j - 1]` at the same time.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
- - Focus on analyzing those values that are not as expected.
-
-After reading the above, do you feel that "dynamic programming" is not that difficult? Try to solve this problem. 🤗
-
-## Step-by-Step Solution
-
-1. Determine the **meaning** of the `dp[i][j]`.
- - `dp[i][j]` represents whether the first `i` letters of `s` are a subsequence of `t`'s first `j` letters.
- - `dp[i][j]` is `true` or `false`.
-2. Determine the `dp` array's initial value.
- - Use an example:
-
- ```
- After initialization, the 'dp' array would be:
- s = "abc", t = "ahbgdc"
- # a h b g d c
- # T T T T T T T # dp[0]
- # a F F F F F F F
- # b F F F F F F F
- # c F F F F F F F
- ```
- - `dp[0][j] = true` because `dp[0]` represents the empty string, and empty string is a subsequence of any string.
- - `dp[i][j] = false (i != 0)`.
-3. Fill in the `dp` grid data "in order" according to an example.
-
- ```
- 1. s = "a", t = "ahbgdc"
- # a h b g d c
- # T T T T T T T
- # a F T T T T T T # dp[1]
- ```
- ```
- 2. s = "ab", t = "ahbgdc"
- # a h b g d c
- # T T T T T T T
- # a F T T T T T T
- # b F F F T T T T
- ```
- ```
- 3. s = "abc", t = "ahbgdc"
- # a h b g d c
- # T T T T T T T
- # a F T T T T T T
- # b F F F T T T T
- # c F F F F F F T # dp[3]
- ```
-4. Based on the `dp` grid data, derive the "recursive formula".
-
- ```ruby
- if s[i - 1] == t[j - 1]
- dp[i][j] = dp[i - 1][j - 1]
- else
- dp[i][j] = dp[i][j - 1]
- end
- ```
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
-
-## Complexity
-
-- Time complexity: `O(N * M)`.
-- Space complexity: `O(N * M)`.
-
-## Python
-
-```python
-class Solution:
- def isSubsequence(self, s: str, t: str) -> bool:
- column_count = len(t) + 1
- dp = [[True] * column_count]
- for _ in s:
- dp.append([False] * column_count)
-
- for i in range(1, len(dp)):
- for j in range(1, len(dp[0])):
- if s[i - 1] == t[j - 1]:
- dp[i][j] = dp[i - 1][j - 1]
- else:
- dp[i][j] = dp[i][j - 1]
-
- return dp[-1][-1]
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- bool isSubsequence(string s, string t) {
- vector> dp(s.size() + 1, vector(t.size() + 1));
- fill(dp[0].begin(), dp[0].end(), true);
-
- for (auto i = 1; i < dp.size(); i++) {
- for (auto j = 1; j < dp[0].size(); j++) {
- if (s[i - 1] == t[j - 1]) {
- dp[i][j] = dp[i - 1][j - 1];
- } else {
- dp[i][j] = dp[i][j - 1];
- }
- }
- }
-
- return dp[dp.size() - 1][dp[0].size() - 1];
- }
-};
-```
-
-## JavaScript
-
-```javascript
-var isSubsequence = function (s, t) {
- const dp = Array(s.length + 1).fill().map(
- () => Array(t.length + 1).fill(false)
- )
- dp[0].fill(true)
-
- for (let i = 1; i < dp.length; i++) {
- for (let j = 1; j < dp[0].length; j++) {
- if (s[i - 1] == t[j - 1]) {
- dp[i][j] = dp[i - 1][j - 1]
- } else {
- dp[i][j] = dp[i][j - 1]
- }
- }
- }
-
- return dp.at(-1).at(-1)
-};
-```
-
-## Go
-
-```go
-func isSubsequence(s string, t string) bool {
- dp := make([][]bool, len(s) + 1)
- columnSize := len(t) + 1
- dp[0] = slices.Repeat([]bool{true}, columnSize)
- for i := 1; i < len(dp); i++ {
- dp[i] = make([]bool, columnSize)
- }
-
- for i := 1; i < len(dp); i++ {
- for j := 1; j < len(dp[0]); j++ {
- if s[i - 1] == t[j - 1] {
- dp[i][j] = dp[i - 1][j - 1]
- } else {
- dp[i][j] = dp[i][j - 1]
- }
- }
- }
-
- return dp[len(dp) - 1][len(dp[0]) - 1]
-}
-```
-
-## Java
-
-```java
-class Solution {
- public boolean isSubsequence(String s, String t) {
- var dp = new boolean[s.length() + 1][t.length() + 1];
- Arrays.fill(dp[0], true);
-
- for (var i = 1; i < dp.length; i++) {
- for (var j = 1; j < dp[0].length; j++) {
- if (s.charAt(i - 1) == t.charAt(j - 1)) {
- dp[i][j] = dp[i - 1][j - 1];
- } else {
- dp[i][j] = dp[i][j - 1];
- }
- }
- }
-
- return dp[dp.length - 1][dp[0].length - 1];
- }
-}
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- public bool IsSubsequence(string s, string t)
- {
- var dp = new bool[s.Length + 1, t.Length + 1];
- for (var j = 0; j < dp.GetLength(1); j++)
- dp[0, j] = true;
-
- for (var i = 1; i < dp.GetLength(0); i++)
- {
- for (var j = 1; j < dp.GetLength(1); j++)
- {
- if (s[i - 1] == t[j - 1])
- {
- dp[i, j] = dp[i - 1, j - 1];
- }
- else
- {
- dp[i, j] = dp[i, j - 1];
- }
- }
- }
-
- return dp[dp.GetUpperBound(0), dp.GetUpperBound(1)];
- }
-}
-```
-
-## Ruby
-
-```ruby
-def is_subsequence(s, t)
- dp = Array.new(s.size + 1) do |i|
- Array.new(t.size + 1, i == 0 ? true : false)
- end
-
- (1...dp.size).each do |i|
- (1...dp[0].size).each do |j|
- dp[i][j] =
- if s[i - 1] == t[j - 1]
- dp[i - 1][j - 1]
- else
- dp[i][j - 1]
- end
- end
- end
-
- dp[-1][-1]
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [392. Is Subsequence - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/392-is-subsequence) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/416-partition-equal-subset-sum.md b/en/1-1000/416-partition-equal-subset-sum.md
deleted file mode 100644
index 37cf610..0000000
--- a/en/1-1000/416-partition-equal-subset-sum.md
+++ /dev/null
@@ -1,637 +0,0 @@
-# 416. Partition Equal Subset Sum - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [416. Partition Equal Subset Sum - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/416-partition-equal-subset-sum) for a better experience!
-
-LeetCode link: [416. Partition Equal Subset Sum](https://leetcode.com/problems/partition-equal-subset-sum), difficulty: **Medium**.
-
-## LeetCode description of "416. Partition Equal Subset Sum"
-
-Given an integer array `nums`, return `true` if you can partition the array into two subsets such that the sum of the elements in both subsets is equal or `false` otherwise.
-
-### [Example 1]
-
-**Input**: `nums = [1,5,11,5]`
-
-**Output**: `true`
-
-**Explanation**:
-
-The array can be partitioned as [1, 5, 5] and [11].
-
-
-### [Example 2]
-
-**Input**: `nums = [1,2,3,5]`
-
-**Output**: `false`
-
-**Explanation**:
-
-The array cannot be partitioned into equal sum subsets.
-
-
-### [Constraints]
-
-- `1 <= nums.length <= 200`
-- `1 <= nums[i] <= 100`
-
-## Intuition 1
-
-- When we first see this problem, we might want to loop through all subsets of the array. If there is a subset whose sum is equal to `half of the sum`, then return `true`. This can be achieved with a `backtracking algorithm`, but after seeing the constraint `nums.length <= 200`, we can estimate that the program will time out.
-- This problem can be solved using the `0/1 knapsack problem` algorithm.
-
-## Pattern of "Dynamic Programming"
-
-"Dynamic Programming" requires the use of the `dp` array to store the results. The value of `dp[i][j]` can be converted from its previous (or multiple) values through a formula. Therefore, the value of `dp[i][j]` is derived step by step, and it is related to the previous `dp` record value.
-
-#### "Dynamic programming" is divided into five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
-2. Initialize the value of the array `dp`.
-3. Fill in the `dp` grid data **in order** according to an example.
-4. Based on the `dp` grid data, derive the **recursive formula**.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
-
-#### Detailed description of these five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
- - First determine whether `dp` is a one-dimensional array or a two-dimensional array. A `one-dimensional rolling array` means that the values of the array are overwritten at each iteration. Most of the time, using `one-dimensional rolling array` instead of `two-dimensional array` can simplify the code; but for some problems, such as operating "two swappable arrays", for the sake of ease of understanding, it is better to use `two-dimensional array`.
- - Try to use the meaning of the `return value` required by the problem as the meaning of `dp[i]` (one-dimensional) or `dp[i][j]` (two-dimensional). It works about 60% of the time. If it doesn't work, try other meanings.
- - Try to save more information in the design. Repeated information only needs to be saved once in a `dp[i]`.
- - Use simplified meanings. If the problem can be solved with `boolean value`, don't use `numeric value`.
-2. Initialize the value of the array `dp`. The value of `dp` involves two levels:
- 1. The length of `dp`. Usually: `condition array length plus 1` or `condition array length`.
- 2. The value of `dp[i]` or `dp[i][j]`. `dp[0]` or `dp[0][0]` sometimes requires special treatment.
-3. Fill in the `dp` grid data **in order** according to an example.
- - The "recursive formula" is the core of the "dynamic programming" algorithm. But the "recursive formula" is obscure. If you want to get it, you need to make a table and use data to inspire yourself.
- - If the original example is not good enough, you need to redesign one yourself.
- - According to the example, fill in the `dp` grid data "in order", which is very important because it determines the traversal order of the code.
- - Most of the time, from left to right, from top to bottom. But sometimes it is necessary to traverse from right to left, from bottom to top, from the middle to the right (or left), such as the "palindrome" problems. Sometimes, it is necessary to traverse a line twice, first forward and then backward.
- - When the order is determined correctly, the starting point is determined. Starting from the starting point, fill in the `dp` grid data "in order". This order is also the order in which the program processes.
- - In this process, you will get inspiration to write a "recursive formula". If you can already derive the formula, you do not need to complete the grid.
-4. Based on the `dp` grid data, derive the **recursive formula**.
- - There are three special positions to pay attention to: `dp[i - 1][j - 1]`, `dp[i - 1][j]` and `dp[i][j - 1]`, the current `dp[i][j]` often depends on them.
- - When operating "two swappable arrays", due to symmetry, we may need to use `dp[i - 1][j]` and `dp[i][j - 1]` at the same time.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
- - Focus on analyzing those values that are not as expected.
-
-After reading the above, do you feel that "dynamic programming" is not that difficult? Try to solve this problem. 🤗
-
-## Pattern of "0/1 Knapsack Problem"
-
-The typical "0/1 knapsack problem" means that each "item" can only be used once to fill the "knapsack". "Items" have "weight" and "value" attributes. Find the maximum value of "items" that can be stored in the "knapsack".
-
-Its characteristics are: there is a **set of numbers**, each number can only be used once, and through some calculation, **another number** is obtained. The question can also be turned into whether it can be obtained? How many variations are there? And so on.
-
-Because "0/1 Knapsack Problem" belongs to "Dynamic Programming", I will explain it in the pattern of "Dynamic Programming".
-
-1. Determine what each value of the array `dp` represents.
- - Prefer **one-dimensional rolling array** because the code is concise.
- - Determine what is "item" and what is "knapsack".
- - If `dp[j]` is a boolean value, then `dp[j]` indicates whether the `sum` of the first `i` items can get `j`.
- - If `dp[j]` is a numerical value, then `dp[j]` indicates the maximum (or minimum) value that `dp[j]` can reach using the first `i` items.
-
-2. Initialize the value of the array `dp`.
- - Determine the size of the "knapsack". It is necessary to add 1 to the size of the knapsack, that is, insert `dp[0]` as the starting point, which is convenient for understanding and reference.
- - `dp[0]` sometimes needs special treatment.
-3. According to an example, fill in the `dp` grid data "in order".
- - First in the outer loop, **traverse the items**.
- - Then in the inner loop, **traverse the knapsack size**.
- - When traversing the knapsack size, since `dp[j]` depends on `dp[j]` and `dp[j - weights[i]]`, we should traverse the `dp` array **from right to left**.
- - Please think about whether it is possible to traverse the `dp` array from `left to right`?
-4. According to the `dp` grid data, derive the "recursive formula".
- - If `dp[j]` is a boolean value:
-
- ```cpp
- dp[j] = dp[j] || dp[j - items[i]]
- ```
- - If `dp[j]` is a numeric value:
-
- ```cpp
- dp[j] = min_or_max(dp[j], dp[j - weights[i]] + values[i])
- ```
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
-
-## Step-by-Step Solution
-
-1. Determine the **meaning** of the `dp[j]`
- - `dp[j]` represents whether it is possible to `sum` the first `i` `nums` to get `j`.
- - `dp[j]` is a boolean.
-
-2. Determine the `dp` array's initial value
- - Use an example:
-
- ```
- nums = [1,5,11,5], so 'half of the sum' is 11.
- The `size` of the knapsack is `11 + 1`, and the `items` are `nums`.
- So after initialization, the 'dp' array would be:
- # 0 1 2 3 4 5 6 7 8 9 10 11
- # T F F F F F F F F F F F # dp
- # 1
- # 5
- # 11
- # 5
- ```
- - `dp[0]` is set to `true`, indicating that an empty knapsack can be achieved by not putting any items in it. In addition, it is used as the starting value, and the subsequent `dp[j]` will depend on it. If it is `false`, all values of `dp[j]` will be `false`.
- - `dp[j] = false (j != 0)`, indicating that it is impossible to get `j` with no `nums`.
-3. Fill in the `dp` grid data "in order" according to an example.
-
- ```
- 1. Use the first num '1'.
- # 0 1 2 3 4 5 6 7 8 9 10 11
- # T F F F F F F F F F F F
- # 1 T T F F F F F F F F F F # dp
- ```
-
- ```
- 2. Use the second num '5'.
- # 0 1 2 3 4 5 6 7 8 9 10 11
- # T F F F F F F F F F F F
- # 1 T T F F F F F F F F F F
- # 5 T T F F F T T F F F F F
- ```
-
- ```
- 3. Use the third num '11'.
- # 0 1 2 3 4 5 6 7 8 9 10 11
- # T F F F F F F F F F F F
- # 1 T T F F F F F F F F F F
- # 5 T T F F F T T F F F F F
- # 11 T T F F F T T F F F F T
- ```
-
- ```
- 3. Use the last num '5'.
- # 0 1 2 3 4 5 6 7 8 9 10 11
- # T F F F F F F F F F F F
- # 1 T T F F F F F F F F F F
- # 5 T T F F F T T F F F F F
- # 11 T T F F F T T F F F F T
- # 5 T T F F F T T F F F T T # dp
- ```
-4. Based on the `dp` grid data, derive the "recursive formula".
-
- ```cpp
- dp[j] = dp[j] || dp[j - nums[i]]
- ```
-
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
-
-## Complexity
-
-- Time complexity: `O(n * sum/2)`.
-- Space complexity: `O(sum/2)`.
-
-## Python
-
-```python
-class Solution:
- def canPartition(self, nums: List[int]) -> bool:
- sum_ = sum(nums)
-
- if sum_ % 2 == 1:
- return False
-
- dp = [False] * ((sum_ // 2) + 1)
- dp[0] = True
-
- for num in nums:
- # If not traversing in reverse order, the newly assigned value `dp[j]` will act as `dp[j - num]` later,
- # then the subsequent `dp[j]` will be affected. But each `num` can only be used once!
- j = len(dp) - 1
- while j >= num:
- dp[j] = dp[j] or dp[j - num]
- j -= 1
-
- return dp[-1]
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- public bool CanPartition(int[] nums)
- {
- int sum = nums.Sum();
-
- if (sum % 2 == 1)
- return false;
-
- var dp = new bool[sum / 2 + 1];
- dp[0] = true;
-
- foreach (var num in nums)
- {
- for (var j = dp.GetUpperBound(0); j >= num; j--)
- {
- dp[j] = dp[j] || dp[j - num];
- }
- }
-
- return dp.Last();
- }
-}
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- bool canPartition(vector& nums) {
- auto sum = reduce(nums.begin(), nums.end());
-
- if (sum % 2 == 1) {
- return false;
- }
-
- auto dp = vector(sum / 2 + 1);
- dp[0] = true;
-
- for (auto num : nums) {
- for (auto j = dp.size() - 1; j >= num; j--) {
- dp[j] = dp[j] || dp[j - num];
- }
- }
-
- return dp.back();
- }
-};
-```
-
-## Java
-
-```java
-class Solution {
- public boolean canPartition(int[] nums) {
- var sum = IntStream.of(nums).sum();
-
- if (sum % 2 == 1) {
- return false;
- }
-
- var dp = new boolean[sum / 2 + 1];
- dp[0] = true;
-
- for (var num : nums) {
- for (var j = dp.length - 1; j >= num; j--) {
- dp[j] = dp[j] || dp[j - num];
- }
- }
-
- return dp[dp.length - 1];
- }
-}
-```
-
-## JavaScript
-
-```javascript
-var canPartition = function (nums) {
- const sum = _.sum(nums)
-
- if (sum % 2 == 1) {
- return false
- }
-
- const dp = Array(sum / 2 + 1).fill(false)
- dp[0] = true
-
- for (const num of nums) {
- for (let j = dp.length - 1; j >= num; j--) {
- dp[j] = dp[j] || dp[j - num]
- }
- }
-
- return dp.at(-1)
-};
-```
-
-## Go
-
-```go
-func canPartition(nums []int) bool {
- sum := 0
- for _, num := range nums {
- sum += num
- }
-
- if sum % 2 == 1 {
- return false
- }
-
- dp := make([]bool, sum / 2 + 1)
- dp[0] = true
-
- for _, num := range nums {
- for j := len(dp) - 1; j >= num; j-- {
- dp[j] = dp[j] || dp[j - num]
- }
- }
-
- return dp[len(dp) - 1]
-}
-```
-
-## Ruby
-
-```ruby
-def can_partition(nums)
- sum = nums.sum
-
- return false if sum % 2 == 1
-
- dp = Array.new(sum / 2 + 1, false)
- dp[0] = true
-
- nums.each do |num|
- (num...dp.size).reverse_each do |j|
- dp[j] = dp[j] || dp[j - num]
- end
- end
-
- dp[-1]
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Intuition 2
-
-In solution 1, the traversal order is **from right to left** which really matters.
-
-During the interview, you need to remember it. Is there any way to not worry about the traversal order?
-
-Click to view the answer
As long as you copy the original `dp` and reference the value of the copy, you don't have to worry about the original `dp` value being modified.
-
-## Pattern of "Dynamic Programming"
-
-"Dynamic Programming" requires the use of the `dp` array to store the results. The value of `dp[i][j]` can be converted from its previous (or multiple) values through a formula. Therefore, the value of `dp[i][j]` is derived step by step, and it is related to the previous `dp` record value.
-
-#### "Dynamic programming" is divided into five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
-2. Initialize the value of the array `dp`.
-3. Fill in the `dp` grid data **in order** according to an example.
-4. Based on the `dp` grid data, derive the **recursive formula**.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
-
-#### Detailed description of these five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
- - First determine whether `dp` is a one-dimensional array or a two-dimensional array. A `one-dimensional rolling array` means that the values of the array are overwritten at each iteration. Most of the time, using `one-dimensional rolling array` instead of `two-dimensional array` can simplify the code; but for some problems, such as operating "two swappable arrays", for the sake of ease of understanding, it is better to use `two-dimensional array`.
- - Try to use the meaning of the `return value` required by the problem as the meaning of `dp[i]` (one-dimensional) or `dp[i][j]` (two-dimensional). It works about 60% of the time. If it doesn't work, try other meanings.
- - Try to save more information in the design. Repeated information only needs to be saved once in a `dp[i]`.
- - Use simplified meanings. If the problem can be solved with `boolean value`, don't use `numeric value`.
-2. Initialize the value of the array `dp`. The value of `dp` involves two levels:
- 1. The length of `dp`. Usually: `condition array length plus 1` or `condition array length`.
- 2. The value of `dp[i]` or `dp[i][j]`. `dp[0]` or `dp[0][0]` sometimes requires special treatment.
-3. Fill in the `dp` grid data **in order** according to an example.
- - The "recursive formula" is the core of the "dynamic programming" algorithm. But the "recursive formula" is obscure. If you want to get it, you need to make a table and use data to inspire yourself.
- - If the original example is not good enough, you need to redesign one yourself.
- - According to the example, fill in the `dp` grid data "in order", which is very important because it determines the traversal order of the code.
- - Most of the time, from left to right, from top to bottom. But sometimes it is necessary to traverse from right to left, from bottom to top, from the middle to the right (or left), such as the "palindrome" problems. Sometimes, it is necessary to traverse a line twice, first forward and then backward.
- - When the order is determined correctly, the starting point is determined. Starting from the starting point, fill in the `dp` grid data "in order". This order is also the order in which the program processes.
- - In this process, you will get inspiration to write a "recursive formula". If you can already derive the formula, you do not need to complete the grid.
-4. Based on the `dp` grid data, derive the **recursive formula**.
- - There are three special positions to pay attention to: `dp[i - 1][j - 1]`, `dp[i - 1][j]` and `dp[i][j - 1]`, the current `dp[i][j]` often depends on them.
- - When operating "two swappable arrays", due to symmetry, we may need to use `dp[i - 1][j]` and `dp[i][j - 1]` at the same time.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
- - Focus on analyzing those values that are not as expected.
-
-After reading the above, do you feel that "dynamic programming" is not that difficult? Try to solve this problem. 🤗
-
-## Complexity
-
-- Time complexity: `O(n * sum/2)`.
-- Space complexity: `O(n * sum/2)`.
-
-## Python
-
-```python
-class Solution:
- def canPartition(self, nums: List[int]) -> bool:
- sum_ = sum(nums)
-
- if sum_ % 2 == 1:
- return False
-
- dp = [False] * ((sum_ // 2) + 1)
- dp[0] = True
-
- for num in nums:
- # Make a copy of the 'dp' that has not been modified to eliminate distractions.
- dc = dp.copy()
-
- for j in range(num, len(dp)): # any order is fine
- dp[j] = dc[j] or dc[j - num] # Use 'dc' instead of 'dp' because 'dp' will be modified.
-
- return dp[-1]
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- public bool CanPartition(int[] nums)
- {
- int sum = nums.Sum();
-
- if (sum % 2 == 1)
- return false;
-
- var dp = new bool[sum / 2 + 1];
- dp[0] = true;
-
- foreach (var num in nums)
- {
- var dc = (bool[])dp.Clone();
-
- for (var j = num; j < dp.Length; j++)
- {
- dp[j] = dc[j] || dc[j - num];
- }
- }
-
- return dp.Last();
- }
-}
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- bool canPartition(vector& nums) {
- auto sum = reduce(nums.begin(), nums.end());
-
- if (sum % 2 == 1) {
- return false;
- }
-
- auto dp = vector(sum / 2 + 1);
- dp[0] = true;
-
- for (auto num : nums) {
- auto dc = dp;
-
- for (auto j = num; j < dp.size(); j++) {
- dp[j] = dc[j] || dc[j - num];
- }
- }
-
- return dp.back();
- }
-};
-```
-
-## Java
-
-```java
-class Solution {
- public boolean canPartition(int[] nums) {
- var sum = IntStream.of(nums).sum();
-
- if (sum % 2 == 1) {
- return false;
- }
-
- var dp = new boolean[sum / 2 + 1];
- dp[0] = true;
-
- for (var num : nums) {
- var dc = dp.clone();
-
- for (var j = num; j < dp.length; j++) {
- dp[j] = dc[j] || dc[j - num];
- }
- }
-
- return dp[dp.length - 1];
- }
-}
-```
-
-## JavaScript
-
-```javascript
-var canPartition = function (nums) {
- const sum = _.sum(nums)
-
- if (sum % 2 == 1) {
- return false
- }
-
- const dp = Array(sum / 2 + 1).fill(false)
- dp[0] = true
-
- for (const num of nums) {
- const dc = [...dp]
-
- for (let j = num; j < dp.length; j++) {
- dp[j] = dc[j] || dc[j - num]
- }
- }
-
- return dp.at(-1)
-};
-```
-
-## Go
-
-```go
-func canPartition(nums []int) bool {
- sum := 0
- for _, num := range nums {
- sum += num
- }
-
- if sum % 2 == 1 {
- return false
- }
-
- dp := make([]bool, sum / 2 + 1)
- dp[0] = true
-
- for _, num := range nums {
- dc := slices.Clone(dp)
-
- for j := num; j < len(dp); j++ {
- dp[j] = dc[j] || dc[j - num]
- }
- }
-
- return dp[len(dp) - 1]
-}
-```
-
-## Ruby
-
-```ruby
-def can_partition(nums)
- sum = nums.sum
-
- return false if sum % 2 == 1
-
- dp = Array.new(sum / 2 + 1, false)
- dp[0] = true
-
- nums.each do |num|
- dc = dp.clone
-
- (num...dp.size).each do |j|
- dp[j] = dc[j] || dc[j - num]
- end
- end
-
- dp[-1]
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [416. Partition Equal Subset Sum - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/416-partition-equal-subset-sum) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/42-trapping-rain-water.md b/en/1-1000/42-trapping-rain-water.md
deleted file mode 100644
index 153b6f4..0000000
--- a/en/1-1000/42-trapping-rain-water.md
+++ /dev/null
@@ -1,263 +0,0 @@
-# 42. Trapping Rain Water (Monotonic Stack)
-LeetCode link: [42. Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water/)
-
-## LeetCode problem description
-Given `n` non-negative integers representing an elevation map where the width of each bar is `1`, compute how much water it can trap after raining.
-
-### Example 1
-
-```
-Input: height = [0,1,0,2,1,0,1,3,2,1,2,1]
-Output: 6
-
-Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1].
-In this case, 6 units of rain water (blue section) are being trapped.
-```
-
-### Example 2
-```
-Input: height = [4,2,0,3,2,5]
-Output: 9
-```
-
-### Constraints
-- `n == height.length`
-- `1 <= n <= 2 * 10000`
-- `0 <= height[i] <= 100000`
-
-## Thoughts
-This problem can be solved using **Monotonic Stack**.
-
-This solution will follow **Monotonic Stack**'s common rule: **only calculating when `pop()` is happening**.
-
-This common rule can be applied to calculating result for **most** of the **Monotonic Stack** problems.
-
-
-
-### Complexity
-* Time: `O(n)`.
-* Space: `O(n)`.
-
-## Java
-```java
-class Solution {
- public int trap(int[] heights) {
- var result = 0;
- var indexStack = new Stack();
-
- for (var i = 0; i < heights.length; i++) {
- while (!indexStack.empty() && heights[indexStack.peek()] <= heights[i]) {
- var poppedIndex = indexStack.pop();
-
- if (indexStack.empty()) {
- break;
- }
-
- var leftHeight = heights[indexStack.peek()];
- var rightHeight = heights[i];
- var heightGap = Math.min(leftHeight, rightHeight) - heights[poppedIndex];
- var width = i - indexStack.peek() - 1;
- result += heightGap * width;
- }
-
- indexStack.push(i);
- }
-
- return result;
- }
-}
-```
-
-## Python
-```python
-class Solution:
- def trap(self, heights: List[int]) -> int:
- result = 0
- index_stack = []
-
- for i, height in enumerate(heights):
- while index_stack and heights[index_stack[-1]] <= height:
- popped_index = index_stack.pop()
-
- if not index_stack:
- break
-
- left_height = heights[index_stack[-1]]
- right_height = height
- height_gap = min(left_height, right_height) - heights[popped_index]
- width = i - index_stack[-1] - 1
- result += height_gap * width
-
- index_stack.append(i)
-
- return result
-```
-
-
-
-## C++
-```cpp
-class Solution {
-public:
- int trap(vector& heights) {
- auto result = 0;
- stack index_stack;
-
- for (auto i = 0; i < heights.size(); i++) {
- auto previous_height = 0;
-
- while (!index_stack.empty() && heights[index_stack.top()] <= heights[i]) {
- auto popped_index = index_stack.top();
- index_stack.pop();
-
- if (index_stack.empty()) {
- break;
- }
-
- auto left_height = heights[index_stack.top()];
- auto right_height = heights[i];
- auto height_gap = min(left_height, right_height) - heights[popped_index];
- auto width = i - index_stack.top() - 1;
- result += height_gap * width;
- }
-
- index_stack.push(i);
- }
-
- return result;
- }
-};
-```
-
-## JavaScript
-```javascript
-var trap = function (heights) {
- let result = 0
- const indexStack = []
-
- heights.forEach((height, i) => {
- while (indexStack.length > 0 && heights[indexStack.at(-1)] <= height) {
- const poppedIndex = indexStack.pop()
-
- if (indexStack.length === 0) {
- break
- }
-
- const leftHeight = heights[indexStack.at(-1)]
- const rightHeight = heights[i]
- const heightGap = Math.min(leftHeight, rightHeight) - heights[poppedIndex]
- const width = i - indexStack.at(-1) - 1
- result += heightGap * width
- }
-
- indexStack.push(i)
- })
-
- return result
-};
-```
-
-
-
-## C#
-```c#
-public class Solution
-{
- public int Trap(int[] heights)
- {
- int result = 0;
- var indexStack = new Stack();
-
- for (var i = 0; i < heights.Length; i++)
- {
- while (indexStack.Count > 0 && heights[indexStack.Peek()] <= heights[i])
- {
- int poppedIndex = indexStack.Pop();
-
- if (indexStack.Count == 0)
- {
- break;
- }
-
- int leftHeight = heights[indexStack.Peek()];
- int rightHeight = heights[i];
- int heightGap = Math.Min(leftHeight, rightHeight) - heights[poppedIndex];
- int width = i - indexStack.Peek() - 1;
- result += heightGap * width;
- }
-
- indexStack.Push(i);
- }
-
- return result;
- }
-}
-```
-
-## Go
-```go
-func trap(heights []int) int {
- result := 0
- indexStack := []int{}
-
- for i, height := range heights {
- for len(indexStack) > 0 && heights[indexStack[len(indexStack) - 1]] <= height {
- poppedIndex := indexStack[len(indexStack) - 1]
- indexStack = indexStack[:len(indexStack) - 1]
-
- if len(indexStack) == 0 {
- break
- }
-
- leftIndex := indexStack[len(indexStack) - 1]
- leftHeight := heights[leftIndex]
- rightHeight := heights[i]
- heightGap := min(leftHeight, rightHeight) - heights[poppedIndex]
- width := i - leftIndex - 1
- result += heightGap * width
- }
-
- indexStack = append(indexStack, i)
- }
-
- return result
-}
-```
-
-
-
-## Ruby
-```ruby
-def trap(heights = [])
- result = 0
- index_stack = []
-
- heights.each_with_index do |height, i|
- while !index_stack.empty? && heights[index_stack.last] <= height
- popped_index = index_stack.pop
-
- break if index_stack.empty?
-
- left_height = heights[index_stack.last]
- right_height = heights[i]
- height_gap = [ left_height, right_height ].min - heights[popped_index]
- width = i - index_stack.last - 1
- result += height_gap * width
- end
-
- index_stack << i
- end
-
- result
-end
-```
-
-## Rust
-```rust
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Other languages
-```
-// Welcome to create a PR to complete the code of this language, thanks!
-```
diff --git a/en/1-1000/433-minimum-genetic-mutation.md b/en/1-1000/433-minimum-genetic-mutation.md
deleted file mode 100644
index dd490ca..0000000
--- a/en/1-1000/433-minimum-genetic-mutation.md
+++ /dev/null
@@ -1,217 +0,0 @@
-# 433. Minimum Genetic Mutation - Best Practices of LeetCode Solutions
-LeetCode link: [433. Minimum Genetic Mutation](https://leetcode.com/problems/minimum-genetic-mutation), difficulty: **Medium**.
-
-## LeetCode description of "433. Minimum Genetic Mutation"
-A gene string can be represented by an 8-character long string, with choices from `A`, `C`, `G`, and `T`.
-
-Suppose we need to investigate a mutation from a gene string `startGene` to a gene string `endGene` where one mutation is defined as one single character changed in the gene string.
-
-* For example, `"AACCGGTT" --> "AACCGGTA"` is one mutation.
-
-There is also a gene bank `bank` that records all the valid gene mutations. A gene must be in `bank` to make it a valid gene string.
-
-Given the two gene strings `startGene` and `endGene` and the gene bank `bank`, return _the minimum number of mutations needed to mutate from `startGene` to `endGene`_. If there is no such a mutation, return `-1`.
-
-Note that the starting point is assumed to be valid, so it might not be included in the bank.
-
-### [Example 1]
-**Input**: `startGene = "AACCGGTT", endGene = "AACCGGTA", bank = ["AACCGGTA"]`
-
-**Output**: `1`
-
-### [Example 2]
-**Input**: `startGene = "AACCGGTT", endGene = "AAACGGTA", bank = ["AACCGGTA","AACCGCTA","AAACGGTA"]`
-
-**Output**: `2`
-
-### [Constraints]
-- `0 <= bank.length <= 10`
-- `startGene.length == endGene.length == bank[i].length == 8`
-- `startGene`, `endGene`, and `bank[i]` consist of only the characters `['A', 'C', 'G', 'T']`.
-
-## Intuition 1
-We can think of this problem as a shortest path problem on a graph: there are `4^8` vertices (strings `'AAAAAAAA'` to `'TTTTTTTT'`), and there is an edge between two vertices if they differ in one character, and if *both* vertices are in `bank`.
-
-So this issue can be solved by **Breadth-First Search** on a undirected graph.
-
-
-
-* As shown in the figure above, **Breadth-First Search** can be thought of as visiting vertices in rounds and rounds. Actually, whenever you see a question is about
- getting `minimum number` of something of a graph, `Breadth-First Search` would probably help.
-
-* `Breadth-First Search` emphasizes first-in-first-out, so a **queue** is needed.
-
-### Approach 1: Breadth-First Search Algorithm
-1. `Breadth-First Search` a graph means traversing **from near to far**, from `circle 1` to `circle N`. Each `circle` is a round of iteration.
-1. So through `Breadth-First Search`, when a word matches `endGene`, the game is over, and we can return the number of **circle** as a result.
-
-### Complexity
-> **N** is the length of `bank`.
-
-* Time: `O((8 * 4) * N)`.
-* Space: `O(N)`.
-
-## Approach 2: A* (A-Star) Search Algorithm
-
-**A-Star Search Algorithm** can be used to greatly improve the performance of **Breadth-First Search Algorithm**.
-
-Please view detailed **A-Star Algorithm** at [752. Open the Lock](./752-open-the-lock.md).
-
-Bellow has code using _A-Star Search Algorithm_ in Python.
-
-## Python
-### Approach 1: Breadth-First Search (way 1)
-```python
-class Solution:
- def minMutation(self, start_gene: str, end_gene: str, bank: List[str]) -> int:
- if not end_gene in bank:
- return -1
-
- self.end_gene = end_gene
- self.bank = set(bank)
- self.queue = deque([start_gene]) # difference 1
- result = 0
-
- while self.queue:
- result += 1 # difference 2
- queue_size = len(self.queue)
-
- for i in range(queue_size): # difference 3
- gene = self.queue.popleft()
-
- if self.mutate_one(gene):
- return result
-
- return -1
-
- def mutate_one(self, gene): # difference 4
- for i in range(len(gene)):
- for char in ['A', 'C', 'G', 'T']:
- if gene[i] == char:
- continue
-
- mutation = f'{gene[:i]}{char}{gene[i + 1:]}'
-
- if mutation == self.end_gene:
- return True
-
- if mutation in self.bank:
- self.queue.append(mutation)
- self.bank.remove(mutation)
-```
-
-### Approach 1: Breadth-First Search (way 2 by adding `mutated_count` in queue's item)
-```python
-class Solution:
- def minMutation(self, start_gene: str, end_gene: str, bank: List[str]) -> int:
- if not end_gene in bank:
- return -1
-
- self.bank = set(bank)
- self.end_gene = end_gene
- self.queue = deque([(start_gene, 0)]) # difference 1
-
- while self.queue:
- gene, mutated_count = self.queue.popleft() # difference 2
-
- if self.mutate_one(gene, mutated_count):
- return mutated_count + 1
-
- return -1
-
- def mutate_one(self, gene, mutated_count): # difference 3
- for i in range(len(gene)):
- for char in ['A', 'C', 'G', 'T']:
- if gene[i] == char:
- continue
-
- mutation = f'{gene[:i]}{char}{gene[i + 1:]}'
-
- if mutation == self.end_gene:
- return True
-
- if mutation in self.bank:
- self.queue.append((mutation, mutated_count + 1))
- self.bank.remove(mutation)
-```
-
-### Approach 2: A* (A-Star) Search Algorithm
-```python
-import heapq
-
-
-class Solution:
- def minMutation(self, start_gene: str, end_gene: str, bank: List[str]) -> int:
- if not end_gene in bank:
- return -1
-
- self.end_gene = end_gene
- bank = set(bank)
- priority_queue = [(self.distance(start_gene), start_gene, 0)] # difference 1
-
- while priority_queue:
- _, gene, mutated_count = heapq.heappop(priority_queue) # difference 2
-
- for i in range(len(gene)):
- for char in ['A', 'C', 'G', 'T']:
- if gene[i] == char:
- continue
-
- mutation = f'{gene[:i]}{char}{gene[i + 1:]}'
-
- if mutation == end_gene:
- return mutated_count + 1
-
- if mutation in bank:
- heapq.heappush(
- priority_queue,
- (self.distance(mutation), mutation, mutated_count + 1)
- ) # difference 3
- bank.remove(mutation)
-
- return -1
-
- def distance(self, gene): # difference 4
- result = 0
-
- for i in range(8):
- if gene[i] != self.end_gene[i]:
- result += 1
-
- return result
-```
-
-## JavaScript
-```javascript
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Java
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## C++
-```cpp
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## C#
-```c#
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Go
-```go
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Ruby
-```ruby
-# Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## C, Kotlin, Swift, Rust or other languages
-```
-// Welcome to create a PR to complete the code of this language, thanks!
-```
diff --git a/en/1-1000/443-string-compression.md b/en/1-1000/443-string-compression.md
deleted file mode 100644
index 5d3586f..0000000
--- a/en/1-1000/443-string-compression.md
+++ /dev/null
@@ -1,447 +0,0 @@
-# 443. String Compression - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [443. String Compression - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/443-string-compression) for a better experience!
-
-LeetCode link: [443. String Compression](https://leetcode.com/problems/string-compression), difficulty: **Medium**.
-
-## LeetCode description of "443. String Compression"
-
-Given an array of characters `chars`, compress it using the following algorithm:
-
-Begin with an empty string `s`. For each group of **consecutive repeating characters** in `chars`:
-
-- If the group's length is `1`, append the character to `s`.
-- Otherwise, append the character followed by the group's length.
-
-The compressed string `s` **should not be returned separately**, but instead, be stored **in the input character array** `chars`. Note that group lengths that are `10` or longer will be split into multiple characters in `chars`.
-
-After you are done **modifying the input array**, return *the new length of the array*.
-
-You must write an algorithm that uses only constant extra space.
-
-### [Example 1]
-
-**Input**: `chars = ["a","a","b","b","c","c","c"]`
-
-**Output**: `Return 6, and the first 6 characters of the input array should be: ["a","2","b","2","c","3"]`
-
-**Explanation**:
-
-The groups are "aa", "bb", and "ccc". This compresses to "a2b2c3".
-
-
-### [Example 2]
-
-**Input**: `chars = ["a"]`
-
-**Output**: `Return 1, and the first character of the input array should be: ["a"]`
-
-**Explanation**:
-
-The only group is "a", which remains uncompressed since it's a single character.
-
-
-### [Example 3]
-
-**Input**: `chars = ["a","b","b","b","b","b","b","b","b","b","b","b","b"]`
-
-**Output**: `Return 4, and the first 4 characters of the input array should be: ["a","b","1","2"].`
-
-**Explanation**:
-
-The groups are "a" and "bbbbbbbbbbbb". This compresses to "ab12".
-
-
-### [Constraints]
-
-- `1 <= chars.length <= 2000`
-- `chars[i]` is a lowercase English letter, uppercase English letter, digit, or symbol.
-
-### [Hints]
-
-
- Hint 1
- How do you know if you are at the end of a consecutive group of characters?
-
-
-
-
-
-## Intuition
-
-We use two pointers (a read pointer `fast` and a write pointer `slow`) and a counter `count` to achieve in-place compression.
-
-1. **Initialization**:
- - Append a sentinel character (e.g., a space " ") to the end of the input array `chars`. This ensures that the last group of consecutive characters can also be correctly processed within the loop. Java and C# is a little different because array is fixed size.
- - `slow = 0`: The `slow` pointer points to the starting character of the current write segment, and it also represents the length of the final compressed array.
- - `count = 1`: Records the number of occurrences of the current consecutive character `chars[slow]`.
-
-2. **Traversal and Compression**:
- - The `fast` pointer starts traversing the array `chars` from index `1` (until the sentinel character).
- - **Case 1: Character Repetition** (`chars[fast]` is equal to `chars[slow]`)
- - Increment `count`.
- - **Case 2: Character Not Repeated** (`chars[fast]` is not equal to `chars[slow]`)
- - **Subcase 1: Count is 1**
- - Please implement it by yourself
- - **Subcase 2: Count is greater than 1**
- - Please implement it by yourself
-
-3. **Return Result**:
- - After the `fast` pointer has traversed the entire array (including the sentinel), the value of the `slow` pointer is the new length of the compressed array.
-
-
-## Pattern of "Fast & Slow Pointers Technique"
-
-```java
-int slow = 0; // slow pointer
-// ...
-
-for (int fast = 1; fast < array_length; fast++) { // This line is the key!
- if (condition_1) {
- // ...
- continue; // 'continue' is better than 'else' because 'else' will introduce more indents
- }
-
- if (condition_2) {
- // ...
- continue; // 'continue' is better than 'else'
- }
-
- // condition_3
- // ...
- slow++;
- // ...
-}
-
-return something;
-```
-
-## Complexity
-
-- Time complexity: `O(N)`.
-- Space complexity: `O(1)`.
-
-## Python
-
-```python
-class Solution:
- def compress(self, chars: List[str]) -> int:
- chars.append(" ") # Append an extra special char to process the last char easier
- slow = 0 # Slow pointer. This is the answer.
- count = 1 # Count of consecutive repeating characters
-
- for fast in range(1, len(chars)):
- if chars[fast] == chars[slow]:
- count += 1
- continue # 'continue' is better than 'else' because 'else' will introduce more indents
-
- if count == 1:
- slow += 1
- # Don't need to append the 'count' when count is 1.
- chars[slow] = chars[fast]
- continue # 'continue' is better than 'else' because 'else' will introduce more indents
-
- # Append the 'count'
- for c in str(count):
- slow += 1
- chars[slow] = c
-
- slow += 1
- chars[slow] = chars[fast]
- count = 1
-
- return slow
-```
-
-## Java
-
-```java
-import java.util.ArrayList;
-import java.util.List;
-
-class Solution {
- public int compress(char[] chars) {
- int slow = 0; // Slow pointer. This is the answer.
- int count = 1; // Count of consecutive repeating characters
-
- for (int fast = 1; fast <= chars.length; fast++) { // it is "<=", not "<"
- var charFast = (fast == chars.length ? ' ' : chars[fast]);
-
- if (charFast == chars[slow]) {
- count++;
- continue; // 'continue' is better than 'else' because 'else' will introduce more indents
- }
-
- if (count == 1) {
- slow++;
- // Don't need to append the 'count' when count is 1.
- if (slow < chars.length) {
- chars[slow] = charFast;
- }
- continue; // 'continue' is better than 'else' because 'else' will introduce more indents
- }
-
- // Append the 'count'
- for (char c : String.valueOf(count).toCharArray()) {
- slow++;
- chars[slow] = c;
- }
-
- slow++;
- if (slow < chars.length) {
- chars[slow] = charFast;
- }
- count = 1;
- }
-
- return slow;
- }
-}
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- int compress(vector& chars) {
- chars.push_back(' '); // Append an extra special char to process the last char easier
- int slow = 0; // Slow pointer. This is the answer.
- int count = 1; // Count of consecutive repeating characters
-
- for (int fast = 1; fast < chars.size(); ++fast) {
- if (chars[fast] == chars[slow]) {
- count++;
- continue; // 'continue' is better than 'else' because 'else' will introduce more indents
- }
-
- if (count == 1) {
- slow++;
- // Don't need to append the 'count' when count is 1.
- chars[slow] = chars[fast];
- continue; // 'continue' is better than 'else' because 'else' will introduce more indents
- }
-
- // Append the 'count'
- for (char c : to_string(count)) {
- slow++;
- chars[slow] = c;
- }
-
- slow++;
- chars[slow] = chars[fast];
- count = 1;
- }
-
- return slow;
- }
-};
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- public int Compress(char[] chars)
- {
- int slow = 0; // Slow pointer. This is the answer.
- int count = 1; // Count of consecutive repeating characters
-
- for (int fast = 1; fast <= chars.Length; fast++)
- { // it is "<=", not "<"
- char charFast = (fast == chars.Length ? ' ' : chars[fast]);
-
- if (charFast == chars[slow])
- {
- count++;
- continue; // 'continue' is better than 'else' because 'else' will introduce more indents
- }
-
- if (count == 1)
- {
- slow++;
- // Don't need to append the 'count' when count is 1.
- if (slow < chars.Length)
- {
- chars[slow] = charFast;
- }
- continue; // 'continue' is better than 'else' because 'else' will introduce more indents
- }
-
- // Append the 'count'
- foreach (char c in count.ToString())
- {
- slow++;
- chars[slow] = c;
- }
-
- slow++;
- if (slow < chars.Length)
- {
- chars[slow] = charFast;
- }
- count = 1;
- }
-
- return slow;
- }
-}
-```
-
-## JavaScript
-
-```javascript
-/**
- * @param {character[]} chars
- * @return {number}
- */
-var compress = function(chars) {
- chars.push(' ') // Append an extra special char to process the last char easier
- let slow = 0 // Slow pointer. This is the answer.
- let count = 1 // Count of consecutive repeating characters
-
- for (let fast = 1; fast < chars.length; fast++) {
- if (chars[fast] === chars[slow]) {
- count++
- continue // 'continue' is better than 'else' because 'else' will introduce more indents
- }
-
- if (count === 1) {
- slow++
- // Don't need to append the 'count' when count is 1.
- chars[slow] = chars[fast]
- continue // 'continue' is better than 'else' because 'else' will introduce more indents
- }
-
- // Append the 'count'
- for (const c of count.toString()) {
- slow++
- chars[slow] = c
- }
-
- slow++
- chars[slow] = chars[fast]
- count = 1
- }
-
- return slow
-}
-```
-
-## Go
-
-```go
-// A test cannot pass. Reason is still unknown
-
-func compress(chars []byte) int {
- chars = append(chars, ' ') // Append an extra special char to process the last char easier
- slow := 0 // Slow pointer. This is the answer.
- count := 1 // Count of consecutive repeating characters
-
- for fast := 1; fast < len(chars); fast++ {
- if chars[fast] == chars[slow] {
- count++
- continue // 'continue' is better than 'else' because 'else' will introduce more indents
- }
-
- if count == 1 {
- slow++
- // Don't need to append the 'count' when count is 1.
- chars[slow] = chars[fast]
- continue // 'continue' is better than 'else' because 'else' will introduce more indents
- }
-
- // Append the 'count'
- for _, c := range strconv.Itoa(count) {
- slow++
- chars[slow] = byte(c)
- }
-
- slow++
- chars[slow] = chars[fast]
- count = 1
- }
-
- return slow
-}
-```
-
-## Ruby
-
-```ruby
-# @param {Character[]} chars
-# @return {Integer}
-def compress(chars)
- chars << " " # Append an extra special char to process the last char easier
- slow = 0 # Slow pointer. This is the answer.
- count = 1 # Count of consecutive repeating characters
-
- (1...chars.length).each do |fast|
- if chars[fast] == chars[slow]
- count += 1
- next # 'next' is better than 'else' because 'else' will introduce more indents
- end
-
- if count == 1
- slow += 1
- # Don't need to append the 'count' when count is 1.
- chars[slow] = chars[fast]
- next # 'next' is better than 'else' because 'else' will introduce more indents
- end
-
- # Append the 'count'
- count.to_s.each_char do |c|
- slow += 1
- chars[slow] = c
- end
-
- slow += 1
- chars[slow] = chars[fast]
- count = 1
- end
-
- slow
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [443. String Compression - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/443-string-compression) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/454-4sum-ii.md b/en/1-1000/454-4sum-ii.md
deleted file mode 100644
index dd5aab8..0000000
--- a/en/1-1000/454-4sum-ii.md
+++ /dev/null
@@ -1,307 +0,0 @@
-# 454. 4Sum II - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [454. 4Sum II - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/454-4sum-ii) for a better experience!
-
-LeetCode link: [454. 4Sum II](https://leetcode.com/problems/4sum-ii), difficulty: **Medium**.
-
-## LeetCode description of "454. 4Sum II"
-
-Given four integer arrays `nums1`, `nums2`, `nums3`, and `nums4` all of length `n`, return the number of tuples `(i, j, k, l)` such that:
-
-- `0 <= i, j, k, l < n`
-- `nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0`
-
-### [Example 1]
-
-**Input**: `nums1 = [1,2], nums2 = [-2,-1], nums3 = [-1,2], nums4 = [0,2]`
-
-**Output**: `2`
-
-**Explanation**:
-
-The two tuples are:
-
-
-- (0, 0, 0, 1) -> nums1[0] + nums2[0] + nums3[0] + nums4[1] = 1 + (-2) + (-1) + 2 = 0
-- (1, 1, 0, 0) -> nums1[1] + nums2[1] + nums3[0] + nums4[0] = 2 + (-1) + (-1) + 0 = 0
-
-
-
-### [Example 2]
-
-**Input**: `nums1 = [0], nums2 = [0], nums3 = [0], nums4 = [0]`
-
-**Output**: `1`
-
-### [Constraints]
-
-- `n == nums1.length`
-- `n == nums2.length`
-- `n == nums3.length`
-- `n == nums4.length`
-- `1 <= n <= 200`
-- `-2^28 <= nums1[i], nums2[i], nums3[i], nums4[i] <= 2^28`
-
-## Intuition
-
-1. Because the final requirement is to take one number from each group of numbers, the four groups of numbers can be split into **two groups of two**.
-2. Count the number of each `sum`. Use `Map` to store, `key` is `sum`, `value` is `count`.
-3. Iterate over `nums3` and `nums4`, if `-(num3 + num4)` exists in `keys` of `Map`, then `count` is included in the total.
-
-## Step-by-Step Solution
-
-1. Count the number of each `sum`. Use `Map` to store, `key` is `sum`, `value` is `count`.
-
- ```python
- num_to_count = defaultdict(int)
-
- for num1 in nums1:
- for num2 in nums2:
- num_to_count[num1 + num2] += 1
- ```
-
-2. Iterate over `nums3` and `nums4`, if `-(num3 + num4)` exists in `keys` of `Map`, then `count` is included in the total.
-
- ```python
- result = 0
-
- for num3 in nums3:
- for num4 in nums4:
- result += num_to_count[-(num3 + num4)]
-
- return result
- ```
-
-## Complexity
-
-- Time complexity: `O(N * N)`.
-- Space complexity: `O(N)`.
-
-## Java
-
-```java
-class Solution {
- public int fourSumCount(int[] nums1, int[] nums2, int[] nums3, int[] nums4) {
- var numToCount = new HashMap();
-
- for (var num1 : nums1) {
- for (var num2 : nums2) {
- numToCount.put(
- num1 + num2,
- numToCount.getOrDefault(num1 + num2, 0) + 1
- );
- }
- }
-
- var result = 0;
-
- for (var num3 : nums3) {
- for (var num4 : nums4) {
- result += numToCount.getOrDefault(-(num3 + num4), 0);
- }
- }
-
- return result;
- }
-}
-```
-
-## Python
-
-```python
-# from collections import defaultdict
-
-class Solution:
- def fourSumCount(self, nums1: List[int], nums2: List[int], nums3: List[int], nums4: List[int]) -> int:
- num_to_count = defaultdict(int)
-
- for num1 in nums1:
- for num2 in nums2:
- num_to_count[num1 + num2] += 1
-
- result = 0
-
- for num3 in nums3:
- for num4 in nums4:
- result += num_to_count[-(num3 + num4)]
-
- return result
-```
-
-## JavaScript
-
-```javascript
-var fourSumCount = function (nums1, nums2, nums3, nums4) {
- const numToCount = new Map()
-
- for (const num1 of nums1) {
- for (const num2 of nums2) {
- numToCount.set(num1 + num2, (numToCount.get(num1 + num2) || 0) + 1)
- }
- }
-
- let result = 0
-
- for (const num3 of nums3) {
- for (const num4 of nums4) {
- result += numToCount.get(-(num3 + num4)) || 0
- }
- }
-
- return result
-};
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- public int FourSumCount(int[] nums1, int[] nums2, int[] nums3, int[] nums4)
- {
- var numToCount = new Dictionary();
-
- foreach (int num1 in nums1)
- {
- foreach (int num2 in nums2)
- {
- numToCount[num1 + num2] = numToCount.GetValueOrDefault(num1 + num2, 0) + 1;
- }
- }
-
- int result = 0;
-
- foreach (int num3 in nums3)
- {
- foreach (int num4 in nums4)
- {
- result += numToCount.GetValueOrDefault(-(num3 + num4), 0);
- }
- }
-
- return result;
- }
-}
-```
-
-## Ruby
-
-```ruby
-def four_sum_count(nums1, nums2, nums3, nums4)
- num_to_count = Hash.new(0)
-
- nums1.each do |num1|
- nums2.each do |num2|
- num_to_count[num1 + num2] += 1
- end
- end
-
- result = 0
-
- nums3.each do |num3|
- nums4.each do |num4|
- result += num_to_count[-(num3 + num4)]
- end
- end
-
- result
-end
-```
-
-## Go
-
-```go
-func fourSumCount(nums1 []int, nums2 []int, nums3 []int, nums4 []int) int {
- // Create map to store sum frequencies from first two arrays
- sumCount := make(map[int]int)
-
- // Calculate all possible sums from nums1 and nums2
- for _, num1 := range nums1 {
- for _, num2 := range nums2 {
- sumCount[num1 + num2]++
- }
- }
-
- result := 0
- // Check complementary sums from nums3 and nums4
- for _, num3 := range nums3 {
- for _, num4 := range nums4 {
- // Add count of complementary sum that would make total zero
- result += sumCount[-(num3 + num4)]
- }
- }
-
- return result
-}
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- int fourSumCount(vector& nums1, vector& nums2, vector& nums3, vector& nums4) {
- // Store sum frequencies from first two arrays
- unordered_map sumCount;
-
- // Calculate all possible sums from nums1 and nums2
- for (int num1 : nums1) {
- for (int num2 : nums2) {
- sumCount[num1 + num2]++;
- }
- }
-
- int result = 0;
- // Check complementary sums from nums3 and nums4
- for (int num3 : nums3) {
- for (int num4 : nums4) {
- // Add occurrences of required complement sum
- result += sumCount[-(num3 + num4)];
- }
- }
-
- return result;
- }
-};
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [454. 4Sum II - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/454-4sum-ii) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/459-repeated-substring-pattern.md b/en/1-1000/459-repeated-substring-pattern.md
deleted file mode 100644
index 9f21645..0000000
--- a/en/1-1000/459-repeated-substring-pattern.md
+++ /dev/null
@@ -1,251 +0,0 @@
-# 459. Repeated Substring Pattern - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [459. Repeated Substring Pattern - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/459-repeated-substring-pattern) for a better experience!
-
-LeetCode link: [459. Repeated Substring Pattern](https://leetcode.com/problems/repeated-substring-pattern), difficulty: **Easy**.
-
-## LeetCode description of "459. Repeated Substring Pattern"
-
-Given a string `s`, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together.
-
-### [Example 1]
-
-**Input**: `s = "abcabcabcabc"`
-
-**Output**: `true`
-
-**Explanation**:
-
-It is the substring "abc" four times or the substring "abcabc" twice.
-
-
-### [Example 2]
-
-**Input**: `s = "aba"`
-
-**Output**: `false`
-
-### [Constraints]
-
-- `1 <= s.length <= 10000`
-- `s` consists of lowercase English letters.
-
-## Intuition
-
-The key to solving this problem is to see clearly that if `s` can be obtained by repeating the substring, then the starting letter of the substring must be `s[0]`.
-
-Once you understand this, the scope of substring investigation is greatly narrowed.
-
-## Complexity
-
-- Time complexity: `O(N * N)`.
-- Space complexity: `O(N)`.
-
-## Python
-
-```python
-class Solution:
- def repeatedSubstringPattern(self, s: str) -> bool:
- for i in range(1, int(len(s) / 2) + 1):
- if len(s) % i == 0 and s[:i] * int(len(s) / i) == s:
- return True
-
- return False
-```
-
-## JavaScript
-
-```javascript
-var repeatedSubstringPattern = function (s) {
- for (let i = 1; i <= s.length / 2; i++) {
- if (s.length % i != 0) {
- continue
- }
-
- if (s.slice(0, i).repeat(s.length / i) == s) {
- return true
- }
- }
-
- return false
-};
-```
-
-## Go
-
-```go
-func repeatedSubstringPattern(s string) bool {
- n := len(s)
-
- for i := 1; i <= n/2; i++ {
- if n%i == 0 {
- substring := s[:i]
- repeated := strings.Repeat(substring, n/i)
-
- if repeated == s {
- return true
- }
- }
- }
-
- return false
-}
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- bool repeatedSubstringPattern(string s) {
- int n = s.length();
-
- for (int i = 1; i <= n / 2; i++) {
- if (n % i != 0) {
- continue;
- }
-
- string pattern = s.substr(0, i);
- string repeated = "";
-
- for (int j = 0; j < n / i; j++) {
- repeated += pattern;
- }
-
- if (repeated == s) {
- return true;
- }
- }
-
- return false;
- }
-};
-```
-
-## Java
-
-```java
-class Solution {
- public boolean repeatedSubstringPattern(String s) {
- int n = s.length();
-
- for (var i = 1; i <= n / 2; i++) {
- if (n % i != 0) {
- continue;
- }
-
- var pattern = s.substring(0, i);
- var repeated = new StringBuilder();
-
- // Simply concatenate the pattern multiple times
- for (var j = 0; j < n / i; j++) {
- repeated.append(pattern);
- }
-
- // Compare the constructed string with the original string
- if (repeated.toString().equals(s)) {
- return true;
- }
- }
-
- return false;
- }
-}
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- public bool RepeatedSubstringPattern(string s)
- {
- int n = s.Length;
-
- for (int i = 1; i <= n / 2; i++)
- {
- if (n % i != 0)
- {
- continue;
- }
-
- // Get the potential substring pattern
- string pattern = s.Substring(0, i);
- StringBuilder repeated = new StringBuilder();
-
- // Simply concatenate the pattern multiple times
- for (int j = 0; j < n / i; j++)
- {
- repeated.Append(pattern);
- }
-
- // Compare the constructed string with the original string
- if (repeated.ToString() == s)
- {
- return true;
- }
- }
-
- return false;
- }
-}
-```
-
-## Ruby
-
-```ruby
-# @param {String} s
-# @return {Boolean}
-def repeated_substring_pattern(s)
- (0...s.size / 2).each do |i|
- next unless s.size % (i + 1) == 0
-
- if s[0..i] * (s.size / (i + 1)) == s
- return true
- end
- end
-
- false
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [459. Repeated Substring Pattern - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/459-repeated-substring-pattern) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/463-island-perimeter.md b/en/1-1000/463-island-perimeter.md
deleted file mode 100644
index dde4d77..0000000
--- a/en/1-1000/463-island-perimeter.md
+++ /dev/null
@@ -1,215 +0,0 @@
-# LeetCode 463. Island Perimeter's Solution
-LeetCode link: [463. Island Perimeter](https://leetcode.com/problems/island-perimeter)
-
-## LeetCode problem description
-You are given `row x col` `grid` representing a map where `grid[i][j] = 1` represents land and `grid[i][j] = 0` represents water.
-
-Grid cells are connected **horizontally/vertically** (not diagonally). The `grid` is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells).
-
-The island doesn't have "lakes", meaning the water inside isn't connected to the water around the island. One cell is a square with side length 1. The grid is rectangular, width and height don't exceed 100. Determine the perimeter of the island.
-
-### Example 1
-
-```
-Input: grid = [
- [0,1,0,0],
- [1,1,1,0],
- [0,1,0,0],
- [1,1,0,0]
-]
-Output: 16
-Explanation: The perimeter is the 16 yellow stripes in the image above.
-```
-
-### Example 2
-```
-Input: grid = [[1]]
-Output: 4
-```
-
-### Example 3
-```
-Input: grid = [[1,0]]
-Output: 4
-```
-
-### Constraints
-- `row == grid.length`
-- `col == grid[i].length`
-- `1 <= row, col <= 100`
-- `grid[i][j]` is `0` or `1`.
-- There is exactly one island in `grid`.
-
-## Intuition and Approach 1: Straightforward
-1. To calculate the perimeter of an island, we simply add up the number of water-adjacent edges of all water-adjacent lands.
-2. When traversing the grid, once land is found, the number of its adjacent water edges is calculated.
-
-## Intuition 2
-The island problem can be abstracted into a **graph theory** problem. This is an **undirected graph**:
-
-
-
-And this graph has only one **connected components** (island).
-
-## Approach 2: Depth-First Search the Island (complex way)
-1. Find the first land.
-1. Starting at the first land, find all the lands of the island.
- * There are two major ways to explore a `connected component` (island): **Depth-First Search** (DFS) and **Breadth-First Search** (BFS).
- * For **Depth-First Search**, there are two ways to make it: `Recursive` and `Iterative`. Here I will provide the `Recursive` solution.
- * If you want to know **Depth-First Search** `Iterative` solution, please see [200. Number of Islands (Depth-First Search by Iteration)](200-number-of-islands-2.md).
- * If you want to know **Breadth-First Search** solution, please see [200. Number of Islands (Breadth-First Search)](200-number-of-islands-3.md).
- * Mark each found land as `8` which represents `visited`. Visited lands don't need to be visited again.
-1. To calculate the perimeter of an island, we simply add up the number of water-adjacent edges of all water-adjacent lands.
-1. To solve this problem, you don't really need to use `DFS` or `BFS`, but mastering `DFS` and `BFS` is absolutely necessary.
-
-## Complexity
-* Time: `O(n * m)`.
-* Space: `O(1)`.
-
-## Python
-### Solution 1: Straightforward
-```python
-class Solution:
- def __init__(self):
- self.grid = None
-
- def islandPerimeter(self, grid: List[List[int]]) -> int:
- self.grid = grid
- perimeter = 0
-
- for i in range(len(grid)):
- for j in range(len(grid[0])):
- if grid[i][j] == 1:
- perimeter += self.water_side_count(i, j)
-
- return perimeter
-
- def water_side_count(self, i, j):
- side_count = 0
-
- for a, b in [
- (-1, 0),
- (0, -1), (0, 1),
- (1, 0),
- ]:
- m = i + a
- n = j + b
-
- if m < 0 or n < 0 or m >= len(self.grid) or n >= len(self.grid[0]) \
- or self.grid[m][n] == 0:
- side_count += 1
-
- return side_count
-```
-
-### Solution 2: Depth-First Search the Island (complex way)
-```python
-class Solution:
- def __init__(self):
- self.perimeter = 0
- self.grid = None
-
- def islandPerimeter(self, grid: List[List[int]]) -> int:
- self.grid = grid
-
- for i, row in enumerate(self.grid):
- for j, value in enumerate(row):
- if value == 1:
- self.depth_first_search(i, j)
-
- return self.perimeter
-
- def depth_first_search(self, i, j):
- if i < 0 or i >= len(self.grid):
- return
-
- if j < 0 or j >= len(self.grid[0]):
- return
-
- if self.grid[i][j] != 1:
- return
-
- self.grid[i][j] = 8
-
- self.perimeter += self.water_edges(i, j)
-
- self.depth_first_search(i - 1, j)
- self.depth_first_search(i, j + 1)
- self.depth_first_search(i + 1, j)
- self.depth_first_search(i, j - 1)
-
- def water_edges(self, i, j):
- result = 0
- result += self.water_edge(i - 1, j)
- result += self.water_edge(i, j + 1)
- result += self.water_edge(i + 1, j)
- result += self.water_edge(i, j - 1)
- return result
-
- def water_edge(self, i, j):
- if i < 0 or i >= len(self.grid):
- return 1
-
- if j < 0 or j >= len(self.grid[0]):
- return 1
-
- if self.grid[i][j] == 0:
- return 1
-
- return 0
-```
-
-## Java
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## C++
-```cpp
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## JavaScript
-```javascript
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## C#
-```c#
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Go
-```go
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Ruby
-```ruby
-# Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## C
-```c
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Kotlin
-```kotlin
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Swift
-```swift
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Rust
-```rust
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Other languages
-```
-// Welcome to create a PR to complete the code of this language, thanks!
-```
diff --git a/en/1-1000/474-ones-and-zeroes.md b/en/1-1000/474-ones-and-zeroes.md
deleted file mode 100644
index e64e357..0000000
--- a/en/1-1000/474-ones-and-zeroes.md
+++ /dev/null
@@ -1,504 +0,0 @@
-# 474. Ones and Zeroes - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [474. Ones and Zeroes - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/474-ones-and-zeroes) for a better experience!
-
-LeetCode link: [474. Ones and Zeroes](https://leetcode.com/problems/ones-and-zeroes), difficulty: **Medium**.
-
-## LeetCode description of "474. Ones and Zeroes"
-
-You are given an array of binary strings `strs` and two integers `m` and `n`.
-
-Return the size of the largest subset of `strs` such that there are **at most** `m` `0`'s and `n` `1`'s in the subset.
-
-A set `x` is a **subset** of a set `y` if all elements of `x` are also elements of `y`.
-
-### [Example 1]
-
-**Input**: `strs = ["10","0001","111001","1","0"], m = 5, n = 3`
-
-**Output**: `4`
-
-**Explanation**:
-
-The largest subset with at most 5 0's and 3 1's is {"10", "0001", "1", "0"}, so the answer is 4.
-Other valid but smaller subsets include {"0001", "1"} and {"10", "1", "0"}.
-{"111001"} is an invalid subset because it contains 4 1's, greater than the maximum of 3.
-
-
-### [Example 2]
-
-**Input**: `strs = ["10","0","1"], m = 1, n = 1`
-
-**Output**: `2`
-
-**Explanation**:
-
-The largest subset is {"0", "1"}, so the answer is 2.
-
-
-### [Constraints]
-
-- `1 <= strs.length <= 600`
-- `1 <= strs[i].length <= 100`
-- `'strs[i]' consists only of digits '0' and '1'`
-- `1 <= m, n <= 100`
-
-## Intuition
-
-This question is difficult. It is recommended to complete a simple question of the same type first [416. Partition Equal Subset Sum](416-partition-equal-subset-sum.md).
-
-- After completing 416, you will find that this question requires solving the `0/1 Knapsack Problem` in two dimensions.
-- The solution is to first solve the problem in one dimension and then expand it to two dimensions.
-- It is no need to draw a grid that considers both dimensions together, that's too complicated. Let's first **only** consider the quantity limit of `0`.
-
-## Pattern of "Dynamic Programming"
-
-"Dynamic Programming" requires the use of the `dp` array to store the results. The value of `dp[i][j]` can be converted from its previous (or multiple) values through a formula. Therefore, the value of `dp[i][j]` is derived step by step, and it is related to the previous `dp` record value.
-
-#### "Dynamic programming" is divided into five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
-2. Initialize the value of the array `dp`.
-3. Fill in the `dp` grid data **in order** according to an example.
-4. Based on the `dp` grid data, derive the **recursive formula**.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
-
-#### Detailed description of these five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
- - First determine whether `dp` is a one-dimensional array or a two-dimensional array. A `one-dimensional rolling array` means that the values of the array are overwritten at each iteration. Most of the time, using `one-dimensional rolling array` instead of `two-dimensional array` can simplify the code; but for some problems, such as operating "two swappable arrays", for the sake of ease of understanding, it is better to use `two-dimensional array`.
- - Try to use the meaning of the `return value` required by the problem as the meaning of `dp[i]` (one-dimensional) or `dp[i][j]` (two-dimensional). It works about 60% of the time. If it doesn't work, try other meanings.
- - Try to save more information in the design. Repeated information only needs to be saved once in a `dp[i]`.
- - Use simplified meanings. If the problem can be solved with `boolean value`, don't use `numeric value`.
-2. Initialize the value of the array `dp`. The value of `dp` involves two levels:
- 1. The length of `dp`. Usually: `condition array length plus 1` or `condition array length`.
- 2. The value of `dp[i]` or `dp[i][j]`. `dp[0]` or `dp[0][0]` sometimes requires special treatment.
-3. Fill in the `dp` grid data **in order** according to an example.
- - The "recursive formula" is the core of the "dynamic programming" algorithm. But the "recursive formula" is obscure. If you want to get it, you need to make a table and use data to inspire yourself.
- - If the original example is not good enough, you need to redesign one yourself.
- - According to the example, fill in the `dp` grid data "in order", which is very important because it determines the traversal order of the code.
- - Most of the time, from left to right, from top to bottom. But sometimes it is necessary to traverse from right to left, from bottom to top, from the middle to the right (or left), such as the "palindrome" problems. Sometimes, it is necessary to traverse a line twice, first forward and then backward.
- - When the order is determined correctly, the starting point is determined. Starting from the starting point, fill in the `dp` grid data "in order". This order is also the order in which the program processes.
- - In this process, you will get inspiration to write a "recursive formula". If you can already derive the formula, you do not need to complete the grid.
-4. Based on the `dp` grid data, derive the **recursive formula**.
- - There are three special positions to pay attention to: `dp[i - 1][j - 1]`, `dp[i - 1][j]` and `dp[i][j - 1]`, the current `dp[i][j]` often depends on them.
- - When operating "two swappable arrays", due to symmetry, we may need to use `dp[i - 1][j]` and `dp[i][j - 1]` at the same time.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
- - Focus on analyzing those values that are not as expected.
-
-After reading the above, do you feel that "dynamic programming" is not that difficult? Try to solve this problem. 🤗
-
-## Pattern of "0/1 Knapsack Problem"
-
-The typical "0/1 knapsack problem" means that each "item" can only be used once to fill the "knapsack". "Items" have "weight" and "value" attributes. Find the maximum value of "items" that can be stored in the "knapsack".
-
-Its characteristics are: there is a **set of numbers**, each number can only be used once, and through some calculation, **another number** is obtained. The question can also be turned into whether it can be obtained? How many variations are there? And so on.
-
-Because "0/1 Knapsack Problem" belongs to "Dynamic Programming", I will explain it in the pattern of "Dynamic Programming".
-
-1. Determine what each value of the array `dp` represents.
- - Prefer **one-dimensional rolling array** because the code is concise.
- - Determine what is "item" and what is "knapsack".
- - If `dp[j]` is a boolean value, then `dp[j]` indicates whether the `sum` of the first `i` items can get `j`.
- - If `dp[j]` is a numerical value, then `dp[j]` indicates the maximum (or minimum) value that `dp[j]` can reach using the first `i` items.
-
-2. Initialize the value of the array `dp`.
- - Determine the size of the "knapsack". It is necessary to add 1 to the size of the knapsack, that is, insert `dp[0]` as the starting point, which is convenient for understanding and reference.
- - `dp[0]` sometimes needs special treatment.
-3. According to an example, fill in the `dp` grid data "in order".
- - First in the outer loop, **traverse the items**.
- - Then in the inner loop, **traverse the knapsack size**.
- - When traversing the knapsack size, since `dp[j]` depends on `dp[j]` and `dp[j - weights[i]]`, we should traverse the `dp` array **from right to left**.
- - Please think about whether it is possible to traverse the `dp` array from `left to right`?
-4. According to the `dp` grid data, derive the "recursive formula".
- - If `dp[j]` is a boolean value:
-
- ```cpp
- dp[j] = dp[j] || dp[j - items[i]]
- ```
- - If `dp[j]` is a numeric value:
-
- ```cpp
- dp[j] = min_or_max(dp[j], dp[j - weights[i]] + values[i])
- ```
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
-
-## Step-by-Step Solution
-
-1. Determine the **meaning** of the `dp[j]`
- - Since we are only considering the zero count constraint for now, we can use a one-dimensional `dp` array.
- - `items` is `strs`, `backpack` is `max_zero_count`.
- - `dp[j]` represents the maximum number of strings that can be selected with at most `j` zeros.
- - `dp[j]` is an integer.
-
-2. Determine the `dp` array's initial value
- - Use an example, example 1: `Input: strs = ["10","0001","111001","1","0"], m = 5, n = 3`.
- - After initialization:
- ```python
- max_zero_count = m
- dp = [0] * (max_zero_count + 1)
- ```
- - `dp[0] = 0`, indicating that with no zeros, we can select 0 strings.
- - `dp[j] = 0` as the initial value because we will use `max` to increase them later.
-
-3. According to an example, fill in the `dp` grid data "in order".
- - Let's analyze the example step by step:
-
- ```
- # Initial state
- # 0 1 2 3 4 5
- # 0 0 0 0 0 0
-
- # After processing "10" (1 zero)
- # 0 1 2 3 4 5
- # 0 1 1 1 1 1
-
- # After processing "0001" (3 zeros)
- # 0 1 2 3 4 5
- # 0 1 1 1 2 2
-
- # After processing "111001" (2 zeros)
- # 0 1 2 3 4 5
- # 0 1 1 2 2 2
-
- # After processing "1" (0 zeros)
- # 0 1 2 3 4 5
- # 0 2 2 3 3 3
-
- # After processing "0" (1 zero)
- # 0 1 2 3 4 5
- # 0 2 3 3 4 4
- ```
-4. According to the `dp` grid data, derive the "recursive formula".
-
- ```cpp
- dp[j] = max(dp[j], dp[j - zero_count] + 1)
- ```
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
- - The code that only considers the quantity limit of `0` is:
-
- ```python
- class Solution:
- def findMaxForm(self, strs: List[str], max_zero_count: int, n: int) -> int:
- dp = [0] * (max_zero_count + 1)
-
- for string in strs:
- zero_count = count_zero(string)
-
- for j in range(len(dp) - 1, zero_count - 1, -1): # must iterate in reverse order!
- dp[j] = max(dp[j], dp[j - zero_count] + 1)
-
- return dp[-1]
-
-
- def count_zero(string):
- zero_count = 0
-
- for bit in string:
- if bit == '0':
- zero_count += 1
-
- return zero_count
- ```
-
-#### Now, you can consider another dimension: the quantity limit of `1`.
-
-It should be handled similarly to `0` but in another dimension. Please see the complete code below.
-
-## Complexity
-
-- Time complexity: `O(N * M * Len)`.
-- Space complexity: `O(N * M)`.
-
-## Python
-
-```python
-class Solution:
- def findMaxForm(self, strs: List[str], max_zero_count: int, max_one_count: int) -> int:
- dp = [[0] * (max_one_count + 1) for _ in range(max_zero_count + 1)]
-
- for string in strs:
- zero_count, one_count = count_zero_one(string)
-
- for i in range(len(dp) - 1, zero_count - 1, -1):
- for j in range(len(dp[0]) - 1, one_count - 1, -1):
- dp[i][j] = max(dp[i][j], dp[i - zero_count][j - one_count] + 1)
-
- return dp[-1][-1]
-
-
-def count_zero_one(string):
- zero_count = 0
- one_count = 0
-
- for bit in string:
- if bit == '0':
- zero_count += 1
- else:
- one_count += 1
-
- return zero_count, one_count
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- int findMaxForm(vector& strs, int max_zero_count, int max_one_count) {
- vector> dp(max_zero_count + 1, vector(max_one_count + 1, 0));
-
- for (auto& str : strs) {
- auto zero_count = 0;
- auto one_count = 0;
-
- for (auto bit : str) {
- if (bit == '0') {
- zero_count++;
- } else {
- one_count++;
- }
- }
-
- for (auto i = max_zero_count; i >= zero_count; i--) {
- for (auto j = max_one_count; j >= one_count; j--) {
- dp[i][j] = max(dp[i][j], dp[i - zero_count][j - one_count] + 1);
- }
- }
- }
-
- return dp[max_zero_count][max_one_count];
- }
-};
-```
-
-## Java
-
-```java
-class Solution {
- public int findMaxForm(String[] strs, int maxZeroCount, int maxOneCount) {
- var dp = new int[maxZeroCount + 1][maxOneCount + 1];
-
- for (var str : strs) {
- var zeroCount = 0;
- var oneCount = 0;
-
- for (var bit : str.toCharArray()) {
- if (bit == '0') {
- zeroCount++;
- } else {
- oneCount++;
- }
- }
-
- for (var i = maxZeroCount; i >= zeroCount; i--) {
- for (var j = maxOneCount; j >= oneCount; j--) {
- dp[i][j] = Math.max(dp[i][j], dp[i - zeroCount][j - oneCount] + 1);
- }
- }
- }
-
- return dp[maxZeroCount][maxOneCount];
- }
-}
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- public int FindMaxForm(string[] strs, int maxZeroCount, int maxOneCount)
- {
- var dp = new int[maxZeroCount + 1, maxOneCount + 1];
-
- foreach (var str in strs)
- {
- var (zeroCount, oneCount) = CountZeroOne(str);
-
- for (var i = maxZeroCount; i >= zeroCount; i--)
- {
- for (var j = maxOneCount; j >= oneCount; j--)
- {
- dp[i, j] = Math.Max(dp[i, j], dp[i - zeroCount, j - oneCount] + 1);
- }
- }
- }
-
- return dp[maxZeroCount, maxOneCount];
- }
-
- (int, int) CountZeroOne(string str)
- {
- var zeroCount = 0;
- var oneCount = 0;
-
- foreach (var bit in str)
- {
- if (bit == '0')
- {
- zeroCount++;
- }
- else
- {
- oneCount++;
- }
- }
-
- return (zeroCount, oneCount);
- }
-}
-```
-
-## JavaScript
-
-```javascript
-var findMaxForm = function (strs, maxZeroCount, maxOneCount) {
- const dp = Array(maxZeroCount + 1).fill().map(
- () => Array(maxOneCount + 1).fill(0)
- )
-
- for (const str of strs) {
- const [zeroCount, oneCount] = countZeroOne(str)
-
- for (let i = dp.length - 1; i >= zeroCount; i--) {
- for (let j = dp[0].length - 1; j >= oneCount; j--) {
- dp[i][j] = Math.max(dp[i][j], dp[i - zeroCount][j - oneCount] + 1)
- }
- }
- }
-
- return dp.at(-1).at(-1)
-};
-
-function countZeroOne(str) {
- let zeroCount = 0
- let oneCount = 0
-
- for (const bit of str) {
- if (bit === '0') {
- zeroCount++
- } else {
- oneCount++
- }
- }
-
- return [zeroCount, oneCount]
-}
-```
-
-## Go
-
-```go
-func findMaxForm(strs []string, maxZeroCount int, maxOneCount int) int {
- dp := make([][]int, maxZeroCount + 1)
- for i := range dp {
- dp[i] = make([]int, maxOneCount + 1)
- }
-
- for _, str := range strs {
- zeroCount, oneCount := countZeroOne(str)
-
- for i := len(dp) - 1; i >= zeroCount; i-- {
- for j := len(dp[0]) - 1; j >= oneCount; j-- {
- dp[i][j] = max(dp[i][j], dp[i - zeroCount][j - oneCount] + 1)
- }
- }
- }
-
- return dp[maxZeroCount][maxOneCount]
-}
-
-func countZeroOne(str string) (int, int) {
- zeroCount := 0
- oneCount := 0
-
- for _, bit := range str {
- if bit == '0' {
- zeroCount++
- } else {
- oneCount++
- }
- }
-
- return zeroCount, oneCount
-}
-```
-
-## Ruby
-
-```ruby
-def find_max_form(strs, max_zero_count, max_one_count)
- dp = Array.new(max_zero_count + 1) do
- Array.new(max_one_count + 1, 0)
- end
-
- strs.each do |string|
- zero_count, one_count = count_zero_one(string)
-
- (zero_count...dp.size).reverse_each do |i|
- (one_count...dp[0].size).reverse_each do |j|
- dp[i][j] = [ dp[i][j], dp[i - zero_count][j - one_count] + 1 ].max
- end
- end
- end
-
- dp[-1][-1]
-end
-
-def count_zero_one(string)
- zero_count = 0
- one_count = 0
-
- string.each_char do |bit|
- if bit == '0'
- zero_count += 1
- else
- one_count += 1
- end
- end
-
- [ zero_count, one_count ]
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [474. Ones and Zeroes - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/474-ones-and-zeroes) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/49-group-anagrams.md b/en/1-1000/49-group-anagrams.md
deleted file mode 100644
index ed3eda9..0000000
--- a/en/1-1000/49-group-anagrams.md
+++ /dev/null
@@ -1,134 +0,0 @@
-# 49. Group Anagrams - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [49. Group Anagrams - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/49-group-anagrams) for a better experience!
-
-LeetCode link: [49. Group Anagrams](https://leetcode.com/problems/group-anagrams), difficulty: **Medium**.
-
-## LeetCode description of "49. Group Anagrams"
-
-Given an array of strings `strs`, group the **anagrams** together. You can return the answer in **any order**.
-
-> An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, using all the original letters exactly once.
-
-### [Example 1]
-
-**Input**: `strs = ["eat", "tea", "tan", "ate", "nat", "bat"]`
-
-**Output**: `[["bat"],["nat","tan"],["ate","eat","tea"]]`
-
-### [Example 2]
-
-**Input**: `strs = [""]`
-
-**Output**: `[[""]]`
-
-### [Example 3]
-
-**Input**: `strs = ["a"]`
-
-**Output**: `[["a"]]`
-
-### [Constraints]
-
-- `1 <= strs.length <= 10^4`
-- `0 <= strs[i].length <= 100`
-- `strs[i]` consists of lowercase English letters.
-
-## Intuition
-
-- Two strings, `bat` and `atb`, what is the fastest way to know that they are anagrams?
-
- Click to view the answer
Sort each string in alphabetical order, and then compare the sorted strings. If they are equal, then they are anagrams.
-
-- But after sorting, the original string is not taken into account, and the result is the grouping of the original string. How to solve it?
-
- Click to view the answer
Use tuples, that is, put the alphabetically sorted string and the original string in a tuple, like this: `("abt", "bat")`.
-
-- All that remains to do is to group this tuple array. What is the easiest way to group?
-
- Click to view the answer
Use `Map`, `key` is the alphabetically sorted string, and value is the array of the original string.
-
-## Complexity
-
-> M = string.length
-
-- Time complexity: `O(N * M * logM)`.
-- Space complexity: `O(N)`.
-
-## Python
-
-```python
-class Solution:
- def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
- pairs = [(''.join(sorted(string)), string) for string in strs]
-
- ordered_to_original = defaultdict(list)
-
- for ordered, original in pairs:
- ordered_to_original[ordered].append(original)
-
- return list(ordered_to_original.values())
-```
-
-## Ruby
-
-```ruby
-# @param {String[]} strs
-# @return {String[][]}
-def group_anagrams(strs)
- result = Hash.new([])
- strs.each do |str|
- result[str.chars.sort.join] += [str]
- end
- result.values
-end
-
-# Or solution 2: More concise way
-
-# @param {String[]} strs
-# @return {String[][]}
-def group_anagrams(strs)
- strs.group_by { |string| string.chars.sort }.values
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [49. Group Anagrams - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/49-group-anagrams) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/494-target-sum.md b/en/1-1000/494-target-sum.md
deleted file mode 100644
index 7f1053b..0000000
--- a/en/1-1000/494-target-sum.md
+++ /dev/null
@@ -1,369 +0,0 @@
-# 494. Target Sum - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [494. Target Sum - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/494-target-sum) for a better experience!
-
-LeetCode link: [494. Target Sum](https://leetcode.com/problems/target-sum), difficulty: **Medium**.
-
-## LeetCode description of "494. Target Sum"
-
-You are given an integer array `nums` and an integer `target`.
-
-You want to build an **expression** out of nums by adding one of the symbols `+` and `-` before each integer in nums and then concatenate all the integers.
-
-- For example, if `nums = [2, 1]`, you can add a `+` before 2 and a `-` before `1` and concatenate them to build the expression `+2-1`.
-
-Return the number of different **expressions** that you can build, which evaluates to `target`.
-
-### [Example 1]
-
-**Input**: `nums = [1,1,1,1,1], target = 3`
-
-**Output**: `5`
-
-**Explanation**:
-
--1 + 1 + 1 + 1 + 1 = 3
-+1 - 1 + 1 + 1 + 1 = 3
-+1 + 1 - 1 + 1 + 1 = 3
-+1 + 1 + 1 - 1 + 1 = 3
-+1 + 1 + 1 + 1 - 1 = 3
-
-
-### [Example 2]
-
-**Input**: `nums = [1], target = 1`
-
-**Output**: `1`
-
-### [Constraints]
-
-- `1 <= nums.length <= 20`
-- `0 <= nums[i] <= 1000`
-- `0 <= sum(nums[i]) <= 1000`
-- `-1000 <= target <= 1000`
-
-## Intuition
-
-This problem is quite difficult if you have not solved similar problems before. So before you start working on this question, it is recommended that you first work on another relatively simple question [416. Partition Equal Subset Sum](416-partition-equal-subset-sum.md) that is similar to this one.
-
-## Pattern of "Dynamic Programming"
-
-"Dynamic Programming" requires the use of the `dp` array to store the results. The value of `dp[i][j]` can be converted from its previous (or multiple) values through a formula. Therefore, the value of `dp[i][j]` is derived step by step, and it is related to the previous `dp` record value.
-
-#### "Dynamic programming" is divided into five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
-2. Initialize the value of the array `dp`.
-3. Fill in the `dp` grid data **in order** according to an example.
-4. Based on the `dp` grid data, derive the **recursive formula**.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
-
-#### Detailed description of these five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
- - First determine whether `dp` is a one-dimensional array or a two-dimensional array. A `one-dimensional rolling array` means that the values of the array are overwritten at each iteration. Most of the time, using `one-dimensional rolling array` instead of `two-dimensional array` can simplify the code; but for some problems, such as operating "two swappable arrays", for the sake of ease of understanding, it is better to use `two-dimensional array`.
- - Try to use the meaning of the `return value` required by the problem as the meaning of `dp[i]` (one-dimensional) or `dp[i][j]` (two-dimensional). It works about 60% of the time. If it doesn't work, try other meanings.
- - Try to save more information in the design. Repeated information only needs to be saved once in a `dp[i]`.
- - Use simplified meanings. If the problem can be solved with `boolean value`, don't use `numeric value`.
-2. Initialize the value of the array `dp`. The value of `dp` involves two levels:
- 1. The length of `dp`. Usually: `condition array length plus 1` or `condition array length`.
- 2. The value of `dp[i]` or `dp[i][j]`. `dp[0]` or `dp[0][0]` sometimes requires special treatment.
-3. Fill in the `dp` grid data **in order** according to an example.
- - The "recursive formula" is the core of the "dynamic programming" algorithm. But the "recursive formula" is obscure. If you want to get it, you need to make a table and use data to inspire yourself.
- - If the original example is not good enough, you need to redesign one yourself.
- - According to the example, fill in the `dp` grid data "in order", which is very important because it determines the traversal order of the code.
- - Most of the time, from left to right, from top to bottom. But sometimes it is necessary to traverse from right to left, from bottom to top, from the middle to the right (or left), such as the "palindrome" problems. Sometimes, it is necessary to traverse a line twice, first forward and then backward.
- - When the order is determined correctly, the starting point is determined. Starting from the starting point, fill in the `dp` grid data "in order". This order is also the order in which the program processes.
- - In this process, you will get inspiration to write a "recursive formula". If you can already derive the formula, you do not need to complete the grid.
-4. Based on the `dp` grid data, derive the **recursive formula**.
- - There are three special positions to pay attention to: `dp[i - 1][j - 1]`, `dp[i - 1][j]` and `dp[i][j - 1]`, the current `dp[i][j]` often depends on them.
- - When operating "two swappable arrays", due to symmetry, we may need to use `dp[i - 1][j]` and `dp[i][j - 1]` at the same time.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
- - Focus on analyzing those values that are not as expected.
-
-After reading the above, do you feel that "dynamic programming" is not that difficult? Try to solve this problem. 🤗
-
-## Step-by-Step Solution
-
-1. Determine the **meaning** of the `dp[j]`
- - `dp[j]` represents that by using the **first** `i` nums, the **number** of different **expressions** that you can build, which evaluates to `j`.
- - `dp[j]` is an **integer**.
-2. Determine the `dp` array's initial value
- - Use an example. We didn't use the `Example 1: Input: nums = [1,1,1,1,1], target = 3` because it is too special and is not a good example for deriving a formula.
- - I made up an example: `nums = [1,2,1,2], target = 4`.
- - First, determine the `size` of the knapsack.
- - The `target` value may be very small, such as `0`, so it alone cannot determine the `size` of the knapsack.
- - The sum of `nums` should also be taken into account to fully cover all knapsack sizes.
- - `target` may be negative, but considering that `+` and `-` are added to `num` arbitrarily, the `dp[j]` should be symmetrical around `0`. So the result of negative `target` `dp[target]` is equal to `dp[abs(target)]`.
- - So the `size` of the knapsack can be `max(sum(nums), target) + 1`.
- - Second, determine what are the `items`. The `items` are the `nums` in this problem.
-
- ```
- So after initialization, the 'dp' array would be:
- # 0 1 2 3 4 5 6
- # 1 0 0 0 0 0 0 # dp
- # 1
- # 2
- # 1
- # 2
- ```
- - `dp[0]` is set to `1`, indicating that an empty knapsack can be achieved by not using any `nums`. In addition, it is used as the starting value, and the subsequent `dp[j]` will depend on it. If it is `0`, all values of `dp[j]` will be `0`.
- - `dp[j] = 0 (j != 0)`, indicating that it is impossible to get `j` with no `nums`.
-3. According to an example, fill in the `dp` grid data "in order".
-
- ```
- 1. Use the first num '1'.
- # 0 1 2 3 4 5 6
- # 1 0 0 0 0 0 0
- # 1 0 1 0 0 0 0 0 # dp
- # 2
- # 1
- # 2
- ```
- ```
- 2. Use the second num '2'.
- # 0 1 2 3 4 5 6
- # 1 0 0 0 0 0 0
- # 1 0 1 0 0 0 0 0
- # 2 0 1 0 1 0 0 0
- # 1
- # 2
- ```
- ```
- 3. Use the third num '1'.
- # 0 1 2 3 4 5 6
- # 1 0 0 0 0 0 0
- # 1 0 1 0 0 0 0 0
- # 2 0 1 0 1 0 0 0
- # 1 2 0 2 0 1 0 0
- # 2
- ```
- ```
- 4. Use the fourth num '2'.
- # 0 1 2 3 4 5 6
- # 1 0 0 0 0 0 0
- # 1 0 1 0 0 0 0 0
- # 2 0 1 0 1 0 0 0
- # 1 2 0 2 0 1 0 0
- # 2 4 0 3 0 2 0 1 # dp
- ```
-4. According to the `dp` grid data, derive the "recursive formula".
-
- ```java
- dp[j] = dp[abs(j - nums[i])] + dp[j + nums[i]]
- ```
- - If `j < nums[i]`, `dp[j - nums[i]]` will raise `array index out of range` exception. So we use the `dp[abs(j - num)]` which is equal to it, because the `dp[j]` are symmetrical around `0`, such as `dp[-j]` equals to `dp[j]` (`-j` is an imaginary index).
- - When `j + nums[i] >= dp.length`, `dp[j + nums[i]]` must be `0` to prevent interference.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
-
-## Complexity
-
-- Time complexity: `O(n * sum)`.
-- Space complexity: `O(n * sum)`.
-
-## C#
-
-```csharp
-public class Solution
-{
- public int FindTargetSumWays(int[] nums, int target)
- {
- target = Math.Abs(target);
-
- var dp = new int[Math.Max(nums.Sum(), target) + 1];
- dp[0] = 1;
-
- foreach (var num in nums)
- {
- var dc = (int[])dp.Clone();
-
- for (var j = 0; j < dp.Length; j++)
- {
- dp[j] = dc[Math.Abs(j - num)] + (j + num < dp.Length ? dc[j + num] : 0);
- }
- }
-
- return dp[target];
- }
-}
-```
-
-## Python
-
-```python
-class Solution:
- def findTargetSumWays(self, nums: List[int], target: int) -> int:
- target = abs(target)
-
- dp = [0] * (max(sum(nums), target) + 1)
- dp[0] = 1
-
- for num in nums:
- dc = dp.copy()
-
- for j in range(len(dp)):
- dp[j] = dc[abs(j - num)] + (dc[j + num] if j + num < len(dp) else 0)
-
- return dp[target]
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- int findTargetSumWays(vector& nums, int target) {
- auto sum = reduce(nums.begin(), nums.end());
- target = abs(target);
-
- auto dp = vector(max(sum, target) + 1);
- dp[0] = 1;
-
- for (auto num : nums) {
- auto dc = dp;
-
- for (auto j = 0; j < dp.size(); j++) {
- dp[j] = dc[abs(j - num)] + (j + num < dp.size() ? dc[j + num] : 0);
- }
- }
-
- return dp[target];
- }
-};
-```
-
-## Java
-
-```java
-class Solution {
- public int findTargetSumWays(int[] nums, int target) {
- var sum = IntStream.of(nums).sum();
- target = Math.abs(target);
-
- var dp = new int[Math.max(sum, target) + 1];
- dp[0] = 1;
-
- for (var num : nums) {
- var dc = dp.clone();
-
- for (var j = 0; j < dp.length; j++) {
- dp[j] = dc[Math.abs(j - num)] + (j + num < dp.length ? dc[j + num] : 0);
- }
- }
-
- return dp[target];
- }
-}
-```
-
-## JavaScript
-
-```javascript
-var findTargetSumWays = function (nums, target) {
- target = Math.abs(target)
-
- const dp = Array(Math.max(_.sum(nums), target) + 1).fill(0)
- dp[0] = 1
-
- for (const num of nums) {
- const dc = [...dp]
-
- for (let j = 0; j < dp.length; j++) {
- dp[j] = dc[Math.abs(j - num)] + (j + num < dp.length ? dc[j + num] : 0)
- }
- }
-
- return dp[target]
-};
-```
-
-## Go
-
-```go
-func findTargetSumWays(nums []int, target int) int {
- sum := 0
- for _, num := range nums {
- sum += num
- }
- target = int(math.Abs(float64(target)))
-
- dp := make([]int, max(sum, target) + 1)
- dp[0] = 1
-
- for _, num := range nums {
- dc := slices.Clone(dp)
-
- for j := 0; j < len(dp); j++ {
- addition := 0
- if j + num < len(dp) {
- addition = dc[j + num]
- }
- dp[j] = dc[int(math.Abs(float64((j - num))))] + addition
- }
- }
-
- return dp[target]
-}
-```
-
-## Ruby
-
-```ruby
-def find_target_sum_ways(nums, target)
- target = target.abs
-
- dp = Array.new([ nums.sum, target ].max + 1, 0)
- dp[0] = 1
-
- nums.each do |num|
- dc = dp.clone
-
- dp.each_with_index do |_, j|
- dp[j] = dc[(j - num).abs] + (j + num < dp.size ? dc[j + num] : 0)
- end
- end
-
- dp[target]
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [494. Target Sum - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/494-target-sum) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/496-next-greater-element-i.md b/en/1-1000/496-next-greater-element-i.md
deleted file mode 100644
index a74e834..0000000
--- a/en/1-1000/496-next-greater-element-i.md
+++ /dev/null
@@ -1,415 +0,0 @@
-# 496. Next Greater Element I
-LeetCode link: [496. Next Greater Element I](https://leetcode.com/problems/next-greater-element-i/)
-
-## LeetCode problem description
-The next greater element of some element `x` in an array is the first greater element that is to the right of `x` in the same array.
-
-You are given two distinct 0-indexed integer arrays `nums1` and `nums2`, where `nums1` is a subset of `nums2`.
-
-For each `0 <= i < nums1.length`, find the index `j` such that `nums1[i] == nums2[j]` and determine the next greater element of `nums2[j]` in `nums2`. If there is no next greater element, then the answer for this query is `-1`.
-
-Return an array `ans` of length `nums1.length` such that `ans[i]` is the next greater element as described above.
-
-```
------------------------------------------------------------------------------------------------
-[Example 1]
-
-Input: nums1 = [4,1,2], nums2 = [1,3,4,2]
-Output: [-1,3,-1]
-
-Explanation: The next greater element for each value of nums1 is as follows:
-- 4 is underlined in nums2 = [1,3,4,2]. There is no next greater element, so the answer is -1.
-- 1 is underlined in nums2 = [1,3,4,2]. The next greater element is 3.
-- 2 is underlined in nums2 = [1,3,4,2]. There is no next greater element, so the answer is -1.
------------------------------------------------------------------------------------------------
-[Example 2]
-
-Input: nums1 = [2,4], nums2 = [1,2,3,4]
-Output: [3,-1]
-
-Explanation: The next greater element for each value of nums1 is as follows:
-- 2 is underlined in nums2 = [1,2,3,4]. The next greater element is 3.
-- 4 is underlined in nums2 = [1,2,3,4]. There is no next greater element, so the answer is -1.
------------------------------------------------------------------------------------------------
-[Constraints]
-
-1 <= nums1.length <= nums2.length <= 1000
-0 <= nums1[i], nums2[i] <= 10000
-All integers in 'nums1' and 'nums2' are unique.
-All the integers of 'nums1' also appear in 'nums2'.
------------------------------------------------------------------------------------------------
-```
-
-## Thoughts
-This problem can be solved using **Monotonic Stack**.
-
-Detailed solutions will be given later, and now only the best practices in 7 languages are given.
-
-### Complexity
-#### Brute force solution
-* Time: `O(n * m)`.
-* Space: `O(n)`.
-
-#### Monotonic stack solution
-* Time: `O(n + m)`.
-* Space: `O(n)`.
-
-## Java
-### Brute force solution
-```java
-class Solution {
- public int[] nextGreaterElement(int[] nums1, int[] nums2) {
- var results = new int[nums1.length];
- Arrays.fill(results, -1);
-
- for (var i = 0; i < nums1.length; i++) {
- var found = false;
-
- for (var num2 : nums2) {
- if (found && num2 > nums1[i]) {
- results[i] = num2;
- break;
- }
-
- if (nums1[i] == num2) {
- found = true;
- }
- }
- }
-
- return results;
- }
-}
-```
-
-### Monotonic stack solution
-```java
-class Solution {
- public int[] nextGreaterElement(int[] nums1, int[] nums2) {
- var numToGreaterNum = new HashMap();
- var stack = new Stack();
-
- for (var num : nums2) {
- while (!stack.empty() && stack.peek() < num) {
- numToGreaterNum.put(stack.pop(), num);
- }
-
- stack.push(num);
- }
-
- var result = new int[nums1.length];
-
- for (var i = 0; i < nums1.length; i++) {
- result[i] = numToGreaterNum.getOrDefault(nums1[i], -1);
- }
-
- return result;
- }
-}
-```
-
-## Python
-### Brute force solution
-```python
-class Solution:
- def nextGreaterElement(self, nums1: List[int], nums2: List[int]) -> List[int]:
- results = [-1] * len(nums1)
-
- for i, num1 in enumerate(nums1):
- found = False
-
- for num2 in nums2:
- if found and num2 > num1:
- results[i] = num2
- break
-
- if num1 == num2:
- found = True
-
- return results
-```
-
-### Monotonic stack solution
-```python
-class Solution:
- def nextGreaterElement(self, nums1: List[int], nums2: List[int]) -> List[int]:
- num_to_greater_num = defaultdict(int)
- stack = []
-
- for num in nums2:
- while stack and num > stack[-1]:
- num_to_greater_num[stack.pop()] = num
-
- stack.append(num)
-
- return [num_to_greater_num[num] or -1 for num in nums1]
-```
-
-## C++
-### Brute force solution
-```cpp
-class Solution {
-public:
- vector nextGreaterElement(vector& nums1, vector& nums2) {
- vector results(nums1.size(), -1);
-
- for (auto i = 0; i < nums1.size(); i++) {
- auto found = false;
-
- for (auto num2 : nums2) {
- if (found && num2 > nums1[i]) {
- results[i] = num2;
- break;
- }
-
- if (nums1[i] == num2) {
- found = true;
- }
- }
- }
-
- return results;
- }
-};
-```
-
-### Monotonic stack solution
-```cpp
-class Solution {
-public:
- vector nextGreaterElement(vector& nums1, vector& nums2) {
- unordered_map num_to_greater_num;
- stack monotonic_stack;
-
- for (auto num : nums2) {
- while (!monotonic_stack.empty() && monotonic_stack.top() < num) {
- num_to_greater_num[monotonic_stack.top()] = num;
- monotonic_stack.pop();
- }
-
- monotonic_stack.push(num);
- }
-
- vector result;
-
- for (auto num : nums1) {
- result.emplace_back(
- num_to_greater_num.contains(num) ? num_to_greater_num[num] : -1
- );
- }
-
- return result;
- }
-};
-```
-
-## JavaScript
-### Brute force solution
-```javascript
-var nextGreaterElement = function (nums1, nums2) {
- const results = Array(nums1.length).fill(-1)
-
- nums1.forEach((num1, i) => {
- let found = false
-
- for (const num2 of nums2) {
- if (found && num2 > num1) {
- results[i] = num2
- break
- }
-
- if (num1 == num2) {
- found = true
- }
- }
- })
-
- return results
-};
-```
-
-### Monotonic stack solution
-```javascript
-var nextGreaterElement = function (nums1, nums2) {
- const numToGreaterNum = {}
- const stack = []
-
- nums2.forEach((num) => {
- while (stack.length > 0 && stack.at(-1) < num) {
- numToGreaterNum[stack.pop()] = num
- }
-
- stack.push(num)
- })
-
- return nums1.map((num) => numToGreaterNum[num] || -1)
-};
-```
-
-## C#
-### Brute force solution
-```c#
-public class Solution
-{
- public int[] NextGreaterElement(int[] nums1, int[] nums2)
- {
- var results = new int[nums1.Length];
- Array.Fill(results, -1);
-
- for (var i = 0; i < nums1.Length; i++)
- {
- bool found = false;
-
- foreach (var num2 in nums2)
- {
- if (found && num2 > nums1[i])
- {
- results[i] = num2;
- break;
- }
-
- if (nums1[i] == num2)
- {
- found = true;
- }
- }
- }
-
- return results;
- }
-}
-```
-
-### Monotonic stack solution
-```c#
-public class Solution
-{
- public int[] NextGreaterElement(int[] nums1, int[] nums2)
- {
- var numToGreater = new Dictionary();
- var stack = new Stack();
-
- foreach (int num in nums2)
- {
- while (stack.Count > 0 && stack.Peek() < num)
- {
- numToGreater[stack.Pop()] = num;
- }
-
- stack.Push(num);
- }
-
- var result = new int[nums1.Length];
-
- for (var i = 0; i < nums1.Length; i++)
- {
- result[i] = numToGreater.GetValueOrDefault(nums1[i], -1);
- }
-
- return result;
- }
-}
-```
-
-## Go
-### Brute force solution
-```go
-func nextGreaterElement(nums1 []int, nums2 []int) []int {
- results := slices.Repeat([]int{-1}, len(nums1))
-
- for i, num1 := range nums1 {
- found := false
-
- for _, num2 := range nums2 {
- if found && num2 > num1 {
- results[i] = num2
- break
- }
-
- if num1 == num2 {
- found = true
- }
- }
- }
-
- return results
-}
-```
-
-### Monotonic stack solution
-```go
-func nextGreaterElement(nums1 []int, nums2 []int) []int {
- numToGreaterNum := map[int]int{}
- stack := []int{}
-
- for _, num := range nums2 {
- for (len(stack) > 0 && stack[len(stack) - 1] < num) {
- numToGreaterNum[stack[len(stack) - 1]] = num
- stack = stack[:len(stack) - 1]
- }
-
- stack = append(stack, num)
- }
-
- results := slices.Repeat([]int{-1}, len(nums1))
-
- for i, num1 := range nums1 {
- if value, ok := numToGreaterNum[num1]; ok {
- results[i] = value
- }
- }
-
- return results
-}
-```
-
-## Ruby
-### Brute force solution
-```ruby
-def next_greater_element(nums1, nums2)
- results = Array.new(nums1.size, -1)
-
- nums1.each_with_index do |num1, i|
- found = false
-
- nums2.each do |num2|
- if found and num2 > num1
- results[i] = num2
- break
- end
-
- found = true if num1 == num2
- end
- end
-
- results
-end
-```
-
-### Monotonic stack solution
-```ruby
-def next_greater_element(nums1, nums2)
- num_to_greater_num = {}
- stack = []
-
- nums2.each do |num|
- while !stack.empty? && stack.last < num
- num_to_greater_num[stack.pop] = num
- end
-
- stack << num
- end
-
- nums1.map { |num| num_to_greater_num[num] || -1 }
-end
-```
-
-## Rust
-```rust
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Other languages
-```
-// Welcome to create a PR to complete the code of this language, thanks!
-```
diff --git a/en/1-1000/5-longest-palindromic-substring.md b/en/1-1000/5-longest-palindromic-substring.md
deleted file mode 100644
index 2602ddf..0000000
--- a/en/1-1000/5-longest-palindromic-substring.md
+++ /dev/null
@@ -1,176 +0,0 @@
-# 5. Longest Palindromic Substring - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [5. Longest Palindromic Substring - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/5-longest-palindromic-substring) for a better experience!
-
-LeetCode link: [5. Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring), difficulty: **Medium**.
-
-## LeetCode description of "5. Longest Palindromic Substring"
-
-Given a string `s`, return *the longest palindromic substring in `s`*.
-
-- A string is **palindromic** if it reads the same forward and backward.
-- A **substring** is a contiguous **non-empty** sequence of characters within a string.
-
-### [Example 1]
-
-**Input**: `s = "babad"`
-
-**Output**: `"bab"`
-
-**Explanation**: `"aba" is also a valid answer.`
-
-### [Example 2]
-
-**Input**: `s = "cbbd"`
-
-**Output**: `"bb"`
-
-### [Constraints]
-
-- `1 <= s.length <= 1000`
-- `s` consist of only digits and English letters.
-
-### [Hints]
-
-
- Hint 1
- How can we reuse a previously computed palindrome to compute a larger palindrome?
-
-
-
-
-
- Hint 2
- If “aba” is a palindrome, is “xabax” a palindrome? Similarly is “xabay” a palindrome?
-
-
-
-
-
- Hint 3
- Complexity based hint:
-If we use brute-force and check whether for every start and end position a substring is a palindrome we have O(n^2) start - end pairs and O(n) palindromic checks. Can we reduce the time for palindromic checks to O(1) by reusing some previous computation.
-
-
-
-
-## Intuition
-
-
-
-## Pattern of "Dynamic Programming"
-
-"Dynamic Programming" requires the use of the `dp` array to store the results. The value of `dp[i][j]` can be converted from its previous (or multiple) values through a formula. Therefore, the value of `dp[i][j]` is derived step by step, and it is related to the previous `dp` record value.
-
-#### "Dynamic programming" is divided into five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
-2. Initialize the value of the array `dp`.
-3. Fill in the `dp` grid data **in order** according to an example.
-4. Based on the `dp` grid data, derive the **recursive formula**.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
-
-#### Detailed description of these five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
- - First determine whether `dp` is a one-dimensional array or a two-dimensional array. A `one-dimensional rolling array` means that the values of the array are overwritten at each iteration. Most of the time, using `one-dimensional rolling array` instead of `two-dimensional array` can simplify the code; but for some problems, such as operating "two swappable arrays", for the sake of ease of understanding, it is better to use `two-dimensional array`.
- - Try to use the meaning of the `return value` required by the problem as the meaning of `dp[i]` (one-dimensional) or `dp[i][j]` (two-dimensional). It works about 60% of the time. If it doesn't work, try other meanings.
- - Try to save more information in the design. Repeated information only needs to be saved once in a `dp[i]`.
- - Use simplified meanings. If the problem can be solved with `boolean value`, don't use `numeric value`.
-2. Initialize the value of the array `dp`. The value of `dp` involves two levels:
- 1. The length of `dp`. Usually: `condition array length plus 1` or `condition array length`.
- 2. The value of `dp[i]` or `dp[i][j]`. `dp[0]` or `dp[0][0]` sometimes requires special treatment.
-3. Fill in the `dp` grid data **in order** according to an example.
- - The "recursive formula" is the core of the "dynamic programming" algorithm. But the "recursive formula" is obscure. If you want to get it, you need to make a table and use data to inspire yourself.
- - If the original example is not good enough, you need to redesign one yourself.
- - According to the example, fill in the `dp` grid data "in order", which is very important because it determines the traversal order of the code.
- - Most of the time, from left to right, from top to bottom. But sometimes it is necessary to traverse from right to left, from bottom to top, from the middle to the right (or left), such as the "palindrome" problems. Sometimes, it is necessary to traverse a line twice, first forward and then backward.
- - When the order is determined correctly, the starting point is determined. Starting from the starting point, fill in the `dp` grid data "in order". This order is also the order in which the program processes.
- - In this process, you will get inspiration to write a "recursive formula". If you can already derive the formula, you do not need to complete the grid.
-4. Based on the `dp` grid data, derive the **recursive formula**.
- - There are three special positions to pay attention to: `dp[i - 1][j - 1]`, `dp[i - 1][j]` and `dp[i][j - 1]`, the current `dp[i][j]` often depends on them.
- - When operating "two swappable arrays", due to symmetry, we may need to use `dp[i - 1][j]` and `dp[i][j - 1]` at the same time.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
- - Focus on analyzing those values that are not as expected.
-
-After reading the above, do you feel that "dynamic programming" is not that difficult? Try to solve this problem. 🤗
-
-## Complexity
-
-- Time complexity: ``.
-- Space complexity: ``.
-
-## Ruby
-
-```ruby
-# @param {String} s
-# @return {String}
-def longest_palindrome(s)
- longest = s[0]
- s = s.chars.join("#")
-
- s.size.times do |i|
- j = 1
-
- while j <= i and i + j < s.size
- break if s[i - j] != s[i + j]
-
- if s[i - j] == '#'
- j += 1
- next
- end
-
- length = j * 2 + 1
-
- if length > longest.size
- longest = s[i - j..i + j]
- end
-
- j += 1
- end
- end
-
- longest.gsub('#', '')
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [5. Longest Palindromic Substring - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/5-longest-palindromic-substring) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/503-next-greater-element-ii.md b/en/1-1000/503-next-greater-element-ii.md
deleted file mode 100644
index c387faf..0000000
--- a/en/1-1000/503-next-greater-element-ii.md
+++ /dev/null
@@ -1,226 +0,0 @@
-# 503. Next Greater Element II
-LeetCode link: [503. Next Greater Element II](https://leetcode.com/problems/next-greater-element-ii/)
-
-## LeetCode problem description
-Given a circular integer array `nums` (i.e., the next element of `nums[nums.length - 1]` is `nums[0]`), return the **next greater number** for every element in `nums`.
-
-The **next greater number** of a number `x` is the first greater number to its traversing-order next in the array, which means you could search circularly to find its next greater number. If it doesn't exist, return `-1` for this number.
-```
-------------------------------------------------------------------------------------
-[Example 1]
-
-Input: nums = [1,2,1]
-Output: [2,-1,2]
-
-Explanation: The first 1's next greater number is 2;
-The number 2 can't find next greater number.
-The second 1's next greater number needs to search circularly, which is also 2.
-------------------------------------------------------------------------------------
-[Example 2]
-
-Input: nums = [1,2,3,4,3]
-Output: [2,3,4,-1,4]
-------------------------------------------------------------------------------------
-[Constraints]
-
-1 <= nums.length <= 10000
--10^9 <= nums[i] <= 10^9
-------------------------------------------------------------------------------------
-```
-
-## Solution 1: Brute Force
-This problem can be solved using **Brute Force**. But if the `nums.length` is much greater, the solution will time out.
-Then We need to use a more efficient algorithm.
-
-Detailed solutions will be given later, and now only the best practices in 7 languages are given.
-
-### Complexity
-* Time: `O(n * n)`.
-* Space: `O(n)`.
-
-## Solution 2: Monotonic Stack Algorithm (more efficient)
-This solution will reduce the time complexity to **O(n)**.
-
-A similar issue is [Next Greater Element I](496-next-greater-element-i.md), you can read it first.
-
-Checkout the `Python` section bellow to view the code.
-
-## Python
-### Solution 2: Monotonic Stack
-```python
-# This is a better test case:
-# [2, 5, 3, 2, 4, 1] for `nums`
-# [2, 5, 3, 2, 4, 1, 2, 5, 3, 2, 4] for `extended_nums`
-
-class Solution:
- def nextGreaterElements(self, nums: List[int]) -> List[int]:
- extended_nums = nums + nums[:-1]
- index_stack = []
- result = [-1] * len(extended_nums)
-
- for i, num in enumerate(extended_nums):
- while index_stack and extended_nums[index_stack[-1]] < num:
- result[index_stack.pop()] = num
-
- index_stack.append(i)
-
- return result[:len(nums)]
-```
-
-### Solution 1: Brute Force
-```python
-class Solution:
- def nextGreaterElements(self, nums: List[int]) -> List[int]:
- results = [-1] * len(nums)
- nums2 = nums + nums
-
- for i, num1 in enumerate(nums):
- for j in range(i + 1, len(nums2)):
- if nums2[j] > num1:
- results[i] = nums2[j]
- break
-
- return results
-```
-
-
-## C#
-```c#
-public class Solution
-{
- public int[] NextGreaterElements(int[] nums)
- {
- int[] nums2 = [..nums, ..nums];
- var results = new int[nums.Length];
- Array.Fill(results, -1);
-
- for (var i = 0; i < nums.Length; i++)
- {
- for (var j = i + 1; j < nums2.Length; j++)
- {
- if (nums2[j] > nums[i])
- {
- results[i] = nums2[j];
- break;
- }
- }
- }
-
- return results;
- }
-}
-```
-
-## Java
-```java
-class Solution {
- public int[] nextGreaterElements(int[] nums) {
- var results = new int[nums.length];
- Arrays.fill(results, -1);
-
- var nums2 = Arrays.copyOf(nums, nums.length * 2);
- System.arraycopy(nums, 0, nums2, nums.length, nums.length);
-
- for (var i = 0; i < nums.length; i++) {
- for (var j = i + 1; j < nums2.length; j++) {
- if (nums2[j] > nums[i]) {
- results[i] = nums2[j];
- break;
- }
- }
- }
-
- return results;
- }
-}
-```
-
-## C++
-```cpp
-class Solution {
-public:
- vector nextGreaterElements(vector& nums) {
- vector results(nums.size(), -1);
- auto nums2 = nums;
- ranges::copy(nums, back_inserter(nums2));
-
- for (auto i = 0; i < nums.size(); i++) {
- for (auto j = i + 1; j < nums2.size(); j++) {
- if (nums2[j] > nums[i]) {
- results[i] = nums2[j];
- break;
- }
- }
- }
-
- return results;
- }
-};
-```
-
-## JavaScript
-```javascript
-var nextGreaterElements = function (nums) {
- const results = Array(nums.length).fill(-1)
- const nums2 = [...nums, ...nums]
-
- for (let i = 0; i < nums.length; i++) {
- for (let j = i + 1; j < nums2.length; j++) {
- if (nums2[j] > nums[i]) {
- results[i] = nums2[j]
- break
- }
- }
- }
-
- return results
-};
-```
-
-## Go
-```go
-func nextGreaterElements(nums []int) []int {
- results := slices.Repeat([]int{-1}, len(nums))
- nums2 := slices.Repeat(nums, 2)
-
- for i, num := range nums {
- for j := i + 1; j < len(nums2); j++ {
- if nums2[j] > num {
- results[i] = nums2[j]
- break
- }
- }
- }
-
- return results
-}
-```
-
-## Ruby
-```ruby
-def next_greater_elements(nums)
- results = Array.new(nums.size, -1)
- nums2 = nums + nums
-
- nums.each_with_index do |num, i|
- ((i + 1)...nums2.size).each do |j|
- if nums2[j] > num
- results[i] = nums2[j]
- break
- end
- end
- end
-
- results
-end
-```
-
-## Rust
-```rust
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Other languages
-```
-// Welcome to create a PR to complete the code of this language, thanks!
-```
diff --git a/en/1-1000/509-fibonacci-number.md b/en/1-1000/509-fibonacci-number.md
deleted file mode 100644
index 4b33956..0000000
--- a/en/1-1000/509-fibonacci-number.md
+++ /dev/null
@@ -1,639 +0,0 @@
-# 509. Fibonacci Number - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [509. Fibonacci Number - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/509-fibonacci-number) for a better experience!
-
-LeetCode link: [509. Fibonacci Number](https://leetcode.com/problems/fibonacci-number), difficulty: **Easy**.
-
-## LeetCode description of "509. Fibonacci Number"
-
-The **Fibonacci numbers**, commonly denoted `F(n)` form a sequence, called the **Fibonacci sequence**, such that each number is the sum of the two preceding ones, starting from `0` and `1`. That is,
-
-> F(0) = 0, F(1) = 1
-> F(n) = F(n - 1) + F(n - 2), for n > 1.
-
-Given `n`, calculate `F(n)`.
-
-### [Example 1]
-
-**Input**: `n = 2`
-
-**Output**: `1`
-
-**Explanation**: `F(2) = F(1) + F(0) = 1 + 0 = 1`
-
-### [Example 2]
-
-**Input**: `n = 3`
-
-**Output**: `2`
-
-**Explanation**: `F(3) = F(2) + F(1) = 1 + 1 = 2`
-
-### [Example 3]
-
-**Input**: `n = 4`
-
-**Output**: `3`
-
-**Explanation**: `F(4) = F(3) + F(2) = 2 + 1 = 3`
-
-### [Constraints]
-
-0 <= n <= 30
-
-## Intuition 1
-
-
-
-## Pattern of "Recursion"
-
-Recursion is an important concept in computer science and mathematics, which refers to the method by which a function calls itself **directly or indirectly** in its definition.
-
-### The core idea of recursion
-
-- **Self-call**: A function calls itself during execution.
-- **Base case**: Equivalent to the termination condition. After reaching the base case, the result can be returned without recursive calls to prevent infinite loops.
-- **Recursive step**: The step by which the problem gradually approaches the "base case".
-
-## Complexity
-
-> If no Map is added to cache known results, the time complexity will rise to O( 2^N )
-
-- Time complexity: `O(N)`.
-- Space complexity: `O(N)`.
-
-## C#
-
-```csharp
-public class Solution {
- IDictionary numToFibNum = new Dictionary();
-
- public int Fib(int n) {
- if (n <= 1) {
- return n;
- }
-
- if (numToFibNum.ContainsKey(n)) {
- return numToFibNum[n];
- }
-
- numToFibNum[n] = Fib(n - 1) + Fib(n - 2);
-
- return numToFibNum[n];
- }
-}
-```
-
-## Python
-
-```python
-class Solution:
- @cache
- def fib(self, n: int) -> int:
- if n <= 1:
- return n
-
- return self.fib(n - 1) + self.fib(n - 2)
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- int fib(int n) {
- if (n <= 1) {
- return n;
- }
-
- if (num_to_fib_num_.contains(n)) {
- return num_to_fib_num_[n];
- }
-
- num_to_fib_num_[n] = fib(n - 1) + fib(n - 2);
-
- return num_to_fib_num_[n];
- }
-
-private:
- unordered_map num_to_fib_num_;
-};
-```
-
-## Java
-
-```java
-class Solution {
- var numToFibNum = new HashMap();
-
- public int fib(int n) {
- if (n <= 1) {
- return n;
- }
-
- if (numToFibNum.containsKey(n)) {
- return numToFibNum.get(n);
- }
-
- numToFibNum.put(n, fib(n - 1) + fib(n - 2));
-
- return numToFibNum.get(n);
- }
-}
-```
-
-## JavaScript
-
-```javascript
-const numToFibNum = new Map()
-
-var fib = function (n) {
- if (n <= 1) {
- return n
- }
-
- if (numToFibNum.has(n)) {
- return numToFibNum.get(n)
- }
-
- numToFibNum.set(n, fib(n - 1) + fib(n - 2))
-
- return numToFibNum.get(n)
-};
-```
-
-## Go
-
-```go
-func fib(m int) int {
- numToFibNum := map[int]int{}
-
- var fibonacci func (int) int
-
- fibonacci = func (n int) int {
- if n <= 1 {
- return n
- }
-
- if result, ok := numToFibNum[n]; ok {
- return result
- }
-
- numToFibNum[n] = fibonacci(n - 1) + fibonacci(n - 2)
- return numToFibNum[n]
- }
-
- return fibonacci(m)
-}
-```
-
-## Ruby
-
-```ruby
-def fib(n)
- return n if n <= 1
-
- @cache = {} if @cache.nil?
-
- return @cache[n] if @cache.key?(n)
-
- @cache[n] = fib(n - 1) + fib(n - 2)
-
- @cache[n]
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Intuition 2
-
-
-
-## Pattern of "Dynamic Programming"
-
-"Dynamic Programming" requires the use of the `dp` array to store the results. The value of `dp[i][j]` can be converted from its previous (or multiple) values through a formula. Therefore, the value of `dp[i][j]` is derived step by step, and it is related to the previous `dp` record value.
-
-#### "Dynamic programming" is divided into five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
-2. Initialize the value of the array `dp`.
-3. Fill in the `dp` grid data **in order** according to an example.
-4. Based on the `dp` grid data, derive the **recursive formula**.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
-
-#### Detailed description of these five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
- - First determine whether `dp` is a one-dimensional array or a two-dimensional array. A `one-dimensional rolling array` means that the values of the array are overwritten at each iteration. Most of the time, using `one-dimensional rolling array` instead of `two-dimensional array` can simplify the code; but for some problems, such as operating "two swappable arrays", for the sake of ease of understanding, it is better to use `two-dimensional array`.
- - Try to use the meaning of the `return value` required by the problem as the meaning of `dp[i]` (one-dimensional) or `dp[i][j]` (two-dimensional). It works about 60% of the time. If it doesn't work, try other meanings.
- - Try to save more information in the design. Repeated information only needs to be saved once in a `dp[i]`.
- - Use simplified meanings. If the problem can be solved with `boolean value`, don't use `numeric value`.
-2. Initialize the value of the array `dp`. The value of `dp` involves two levels:
- 1. The length of `dp`. Usually: `condition array length plus 1` or `condition array length`.
- 2. The value of `dp[i]` or `dp[i][j]`. `dp[0]` or `dp[0][0]` sometimes requires special treatment.
-3. Fill in the `dp` grid data **in order** according to an example.
- - The "recursive formula" is the core of the "dynamic programming" algorithm. But the "recursive formula" is obscure. If you want to get it, you need to make a table and use data to inspire yourself.
- - If the original example is not good enough, you need to redesign one yourself.
- - According to the example, fill in the `dp` grid data "in order", which is very important because it determines the traversal order of the code.
- - Most of the time, from left to right, from top to bottom. But sometimes it is necessary to traverse from right to left, from bottom to top, from the middle to the right (or left), such as the "palindrome" problems. Sometimes, it is necessary to traverse a line twice, first forward and then backward.
- - When the order is determined correctly, the starting point is determined. Starting from the starting point, fill in the `dp` grid data "in order". This order is also the order in which the program processes.
- - In this process, you will get inspiration to write a "recursive formula". If you can already derive the formula, you do not need to complete the grid.
-4. Based on the `dp` grid data, derive the **recursive formula**.
- - There are three special positions to pay attention to: `dp[i - 1][j - 1]`, `dp[i - 1][j]` and `dp[i][j - 1]`, the current `dp[i][j]` often depends on them.
- - When operating "two swappable arrays", due to symmetry, we may need to use `dp[i - 1][j]` and `dp[i][j - 1]` at the same time.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
- - Focus on analyzing those values that are not as expected.
-
-After reading the above, do you feel that "dynamic programming" is not that difficult? Try to solve this problem. 🤗
-
-## Complexity
-
-- Time complexity: `O(N)`.
-- Space complexity: `O(N)`.
-
-## C#
-
-```csharp
-public class Solution
-{
- public int Fib(int n)
- {
- if (n <= 1)
- return n;
-
- var dp = new int[n + 1];
- dp[1] = 1;
-
- for (var i = 2; i < dp.Length; i++)
- {
- dp[i] = dp[i - 1] + dp[i - 2];
- }
-
- return dp[n];
- }
-}
-```
-
-## Python
-
-```python
-class Solution:
- def fib(self, n: int) -> int:
- if n == 0:
- return 0
-
- dp = [0] * (n + 1)
- dp[1] = 1
-
- for i in range(2, len(dp)):
- dp[i] = dp[i - 1] + dp[i - 2]
-
- return dp[-1]
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- int fib(int n) {
- if (n <= 1) {
- return n;
- }
-
- auto dp = vector(n + 1);
- dp[1] = 1;
-
- for (auto i = 2; i < dp.size(); i++) {
- dp[i] = dp[i - 1] + dp[i - 2];
- }
-
- return dp[n];
- }
-};
-```
-
-## Java
-
-```java
-class Solution {
- public int fib(int n) {
- if (n <= 1) {
- return n;
- }
-
- var dp = new int[n + 1];
- dp[1] = 1;
-
- for (var i = 2; i < dp.length; i++) {
- dp[i] = dp[i - 1] + dp[i - 2];
- }
-
- return dp[n];
- }
-}
-```
-
-## JavaScript
-
-```javascript
-var fib = function (n) {
- if (n <= 1) {
- return n
- }
-
- const dp = Array(n + 1).fill(0)
- dp[1] = 1
-
- for (let i = 2; i < dp.length; i++) {
- dp[i] = dp[i - 1] + dp[i - 2]
- }
-
- return dp[n]
-};
-```
-
-## Go
-
-```go
-func fib(n int) int {
- if n == 0 {
- return 0
- }
-
- dp := make([]int, n + 1)
- dp[1] = 1
-
- for i := 2; i <= n; i++ {
- dp[i] = dp[i - 2] + dp[i - 1]
- }
-
- return dp[n]
-}
-```
-
-## Ruby
-
-```ruby
-def fib(n)
- return 0 if n == 0
-
- dp = Array.new(n + 1, 0)
- dp[1] = 1
-
- (2...dp.size).each do |i|
- dp[i] = dp[i - 1] + dp[i - 2]
- end
-
- dp[-1]
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Intuition 3
-
-
-
-## Pattern of "Dynamic Programming"
-
-"Dynamic Programming" requires the use of the `dp` array to store the results. The value of `dp[i][j]` can be converted from its previous (or multiple) values through a formula. Therefore, the value of `dp[i][j]` is derived step by step, and it is related to the previous `dp` record value.
-
-#### "Dynamic programming" is divided into five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
-2. Initialize the value of the array `dp`.
-3. Fill in the `dp` grid data **in order** according to an example.
-4. Based on the `dp` grid data, derive the **recursive formula**.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
-
-#### Detailed description of these five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
- - First determine whether `dp` is a one-dimensional array or a two-dimensional array. A `one-dimensional rolling array` means that the values of the array are overwritten at each iteration. Most of the time, using `one-dimensional rolling array` instead of `two-dimensional array` can simplify the code; but for some problems, such as operating "two swappable arrays", for the sake of ease of understanding, it is better to use `two-dimensional array`.
- - Try to use the meaning of the `return value` required by the problem as the meaning of `dp[i]` (one-dimensional) or `dp[i][j]` (two-dimensional). It works about 60% of the time. If it doesn't work, try other meanings.
- - Try to save more information in the design. Repeated information only needs to be saved once in a `dp[i]`.
- - Use simplified meanings. If the problem can be solved with `boolean value`, don't use `numeric value`.
-2. Initialize the value of the array `dp`. The value of `dp` involves two levels:
- 1. The length of `dp`. Usually: `condition array length plus 1` or `condition array length`.
- 2. The value of `dp[i]` or `dp[i][j]`. `dp[0]` or `dp[0][0]` sometimes requires special treatment.
-3. Fill in the `dp` grid data **in order** according to an example.
- - The "recursive formula" is the core of the "dynamic programming" algorithm. But the "recursive formula" is obscure. If you want to get it, you need to make a table and use data to inspire yourself.
- - If the original example is not good enough, you need to redesign one yourself.
- - According to the example, fill in the `dp` grid data "in order", which is very important because it determines the traversal order of the code.
- - Most of the time, from left to right, from top to bottom. But sometimes it is necessary to traverse from right to left, from bottom to top, from the middle to the right (or left), such as the "palindrome" problems. Sometimes, it is necessary to traverse a line twice, first forward and then backward.
- - When the order is determined correctly, the starting point is determined. Starting from the starting point, fill in the `dp` grid data "in order". This order is also the order in which the program processes.
- - In this process, you will get inspiration to write a "recursive formula". If you can already derive the formula, you do not need to complete the grid.
-4. Based on the `dp` grid data, derive the **recursive formula**.
- - There are three special positions to pay attention to: `dp[i - 1][j - 1]`, `dp[i - 1][j]` and `dp[i][j - 1]`, the current `dp[i][j]` often depends on them.
- - When operating "two swappable arrays", due to symmetry, we may need to use `dp[i - 1][j]` and `dp[i][j - 1]` at the same time.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
- - Focus on analyzing those values that are not as expected.
-
-After reading the above, do you feel that "dynamic programming" is not that difficult? Try to solve this problem. 🤗
-
-## Complexity
-
-- Time complexity: `O(N)`.
-- Space complexity: `O(1)`.
-
-## C#
-
-```csharp
-public class Solution
-{
- public int Fib(int n)
- {
- if (n <= 1)
- return n;
-
- int[] dp = [0, 1];
-
- for (var i = 2; i <= n; i++)
- {
- var dc = (int[])dp.Clone();
-
- dp[0] = dc[1];
- dp[1] = dc[0] + dc[1];
- }
-
- return dp[1];
- }
-}
-```
-
-## Python
-
-```python
-class Solution:
- def fib(self, n: int) -> int:
- if n == 0:
- return 0
-
- dp = [0, 1]
-
- for i in range(2, n + 1):
- dc = dp.copy()
-
- dp[0] = dc[1]
- dp[1] = dc[0] + dc[1]
-
- return dp[1]
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- int fib(int n) {
- if (n <= 1) {
- return n;
- }
-
- vector dp = {0, 1};
-
- for (auto i = 2; i <= n; i++) {
- auto dc = dp;
-
- dp[0] = dc[1];
- dp[1] = dc[0] + dc[1];
- }
-
- return dp[1];
- }
-};
-```
-
-## Java
-
-```java
-class Solution {
- public int fib(int n) {
- if (n <= 1) {
- return n;
- }
-
- int[] dp = {0, 1};
-
- for (var i = 2; i <= n; i++) {
- var dc = dp.clone();
-
- dp[0] = dc[1];
- dp[1] = dc[0] + dc[1];
- }
-
- return dp[1];
- }
-}
-```
-
-## JavaScript
-
-```javascript
-var fib = function (n) {
- if (n <= 1) {
- return n
- }
-
- const dp = [0, 1]
-
- for (let i = 2; i <= n; i++) {
- const dc = [...dp]
-
- dp[0] = dc[1]
- dp[1] = dc[0] + dc[1]
- }
-
- return dp[1]
-};
-```
-
-## Go
-
-```go
-func fib(n int) int {
- if n == 0 {
- return 0
- }
-
- dp := []int{0, 1}
-
- for i := 2; i <= n; i++ {
- dc := slices.Clone(dp)
-
- dp[0] = dc[1]
- dp[1] = dc[0] + dc[1]
- }
-
- return dp[1]
-}
-```
-
-## Ruby
-
-```ruby
-def fib(n)
- return 0 if n == 0
-
- dp = [0, 1]
-
- (2..n).each do |i|
- dc = dp.clone
-
- dp[0] = dc[1]
- dp[1] = dc[0] + dc[1]
- end
-
- dp[1]
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [509. Fibonacci Number - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/509-fibonacci-number) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/518-coin-change-ii.md b/en/1-1000/518-coin-change-ii.md
deleted file mode 100644
index bc1c4cb..0000000
--- a/en/1-1000/518-coin-change-ii.md
+++ /dev/null
@@ -1,186 +0,0 @@
-# 518. Coin Change II
-LeetCode link: [518. Coin Change II](https://leetcode.com/problems/coin-change-ii/)
-
-## LeetCode problem description
-> You are given an integer array `coins` representing coins of different denominations and an integer amount representing a total `amount` of money.
-
-Return the number of combinations that make up that amount. If that amount of money cannot be made up by any combination of the coins, return `0`.
-
-You may assume that you have an infinite number of each kind of coin.
-
-The answer is **guaranteed** to fit into a signed 32-bit integer.
-
-```
-Example 1:
-
-Input: amount = 5, coins = [1,2,5]
-Output: 4
-
-Explanation: there are four ways to make up the amount:
-5=5
-5=2+2+1
-5=2+1+1+1
-5=1+1+1+1+1
-------------------------------------------------------------------------
-
-Example 2:
-
-Input: amount = 3, coins = [2]
-Output: 0
-
-Explanation: the amount of 3 cannot be made up just with coins of 2.
-------------------------------------------------------------------------
-
-Example 3:
-
-Input: amount = 10, coins = [10]
-Output: 1
-------------------------------------------------------------------------
-
-Constraints:
-
-1 <= coins.length <= 300
-1 <= coins[i] <= 5000
-All the values of 'coins' are unique.
-0 <= amount <= 5000
-```
-
-## Thoughts
-It is a `Unbounded Knapsack Problem`.
-
-Detailed solutions will be given later, and now only the best practices in 7 languages are given.
-
-### Complexity
-* Time: `O(n * m)`.
-* Space: `O(n)`.
-
-## C#
-```c#
-public class Solution
-{
- public int Change(int amount, int[] coins)
- {
- var dp = new int[amount + 1];
- dp[0] = 1;
-
- foreach (int coin in coins)
- {
- for (var j = coin; j < dp.Length; j++)
- {
- dp[j] += dp[j - coin];
- }
- }
-
- return dp.Last();
- }
-}
-```
-
-## Python
-```python
-class Solution:
- def change(self, amount: int, coins: List[int]) -> int:
- dp = [0] * (amount + 1)
- dp[0] = 1
-
- for coin in coins:
- for j in range(coin, len(dp)):
- dp[j] += dp[j - coin]
-
- return dp[-1]
-```
-
-## C++
-```cpp
-class Solution {
-public:
- int change(int amount, vector& coins) {
- auto dp = vector(amount + 1, 0);
- dp[0] = 1;
-
- for (auto coin : coins) {
- for (auto j = coin; j < dp.size(); j++) {
- dp[j] += dp[j - coin];
- }
- }
-
- return dp.back();
- }
-};
-```
-
-## Java
-```java
-class Solution {
- public int change(int amount, int[] coins) {
- var dp = new int[amount + 1];
- dp[0] = 1;
-
- for (var coin : coins) {
- for (var j = coin; j < dp.length; j++) {
- dp[j] += dp[j - coin];
- }
- }
-
- return dp[dp.length - 1];
- }
-}
-```
-
-## JavaScript
-```javascript
-var change = function (amount, coins) {
- const dp = Array(amount + 1).fill(0)
- dp[0] = 1
-
- for (const coin of coins) {
- for (let j = coin; j < dp.length; j++) {
- dp[j] += dp[j - coin]
- }
- }
-
- return dp.at(-1);
-};
-```
-
-## Go
-```go
-func change(amount int, coins []int) int {
- dp := make([]int, amount + 1)
- dp[0] = 1
-
- for _, coin := range coins {
- for j := coin; j < len(dp); j++ {
- dp[j] += dp[j - coin]
- }
- }
-
- return dp[len(dp) - 1]
-}
-```
-
-## Ruby
-```ruby
-def change(amount, coins)
- dp = Array.new(amount + 1, 0)
- dp[0] = 1
-
- coins.each do |coin|
- (coin...dp.size).each do |j|
- dp[j] += dp[j - coin]
- end
- end
-
- dp[-1]
-end
-```
-
-## Rust
-```rust
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Other languages
-```
-// Welcome to create a PR to complete the code of this language, thanks!
-```
diff --git a/en/1-1000/53-maximum-subarray.md b/en/1-1000/53-maximum-subarray.md
deleted file mode 100644
index 88e4d9c..0000000
--- a/en/1-1000/53-maximum-subarray.md
+++ /dev/null
@@ -1,420 +0,0 @@
-# 53. Maximum Subarray - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [53. Maximum Subarray - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/53-maximum-subarray) for a better experience!
-
-LeetCode link: [53. Maximum Subarray](https://leetcode.com/problems/maximum-subarray), difficulty: **Medium**.
-
-## LeetCode description of "53. Maximum Subarray"
-
-Given an integer array `nums`, find the `subarray` with the largest sum, and return its sum.
-
-### [Example 1]
-
-**Input**: `nums = [-2,1,-3,4,-1,2,1,-5,4]`
-
-**Output**: `6`
-
-**Explanation**:
-
-The subarray [4,-1,2,1] has the largest sum 6.
-
-
-### [Example 2]
-
-**Input**: `nums = [1]`
-
-**Output**: `1`
-
-**Explanation**: `The subarray [1] has the largest sum 1.`
-
-### [Example 3]
-
-**Input**: `nums = [5,4,-1,7,8]`
-
-**Output**: `23`
-
-**Explanation**:
-
-The subarray [5,4,-1,7,8] has the largest sum 23.
-
-
-### [Constraints]
-
-- `1 <= nums.length <= 10^5`
-- `-10^4 <= nums[i] <= 10^4`
-
-## Intuition 1
-
-- This problem can be solved by using `Greedy Algorithm` (please see `solution 2`), yet here we will use another way.
-- For `nums[i]`:
- 1. If the `previous sum` is negative, we can discard `previous sum`;
- 2. If the `previous sum` is positive, we can add `previous sum` to the `current sum`.
-- Therefore, it meets the characteristics of a `dynamic programming` problem.
-
-## Pattern of "Dynamic Programming"
-
-"Dynamic Programming" requires the use of the `dp` array to store the results. The value of `dp[i][j]` can be converted from its previous (or multiple) values through a formula. Therefore, the value of `dp[i][j]` is derived step by step, and it is related to the previous `dp` record value.
-
-#### "Dynamic programming" is divided into five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
-2. Initialize the value of the array `dp`.
-3. Fill in the `dp` grid data **in order** according to an example.
-4. Based on the `dp` grid data, derive the **recursive formula**.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
-
-#### Detailed description of these five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
- - First determine whether `dp` is a one-dimensional array or a two-dimensional array. A `one-dimensional rolling array` means that the values of the array are overwritten at each iteration. Most of the time, using `one-dimensional rolling array` instead of `two-dimensional array` can simplify the code; but for some problems, such as operating "two swappable arrays", for the sake of ease of understanding, it is better to use `two-dimensional array`.
- - Try to use the meaning of the `return value` required by the problem as the meaning of `dp[i]` (one-dimensional) or `dp[i][j]` (two-dimensional). It works about 60% of the time. If it doesn't work, try other meanings.
- - Try to save more information in the design. Repeated information only needs to be saved once in a `dp[i]`.
- - Use simplified meanings. If the problem can be solved with `boolean value`, don't use `numeric value`.
-2. Initialize the value of the array `dp`. The value of `dp` involves two levels:
- 1. The length of `dp`. Usually: `condition array length plus 1` or `condition array length`.
- 2. The value of `dp[i]` or `dp[i][j]`. `dp[0]` or `dp[0][0]` sometimes requires special treatment.
-3. Fill in the `dp` grid data **in order** according to an example.
- - The "recursive formula" is the core of the "dynamic programming" algorithm. But the "recursive formula" is obscure. If you want to get it, you need to make a table and use data to inspire yourself.
- - If the original example is not good enough, you need to redesign one yourself.
- - According to the example, fill in the `dp` grid data "in order", which is very important because it determines the traversal order of the code.
- - Most of the time, from left to right, from top to bottom. But sometimes it is necessary to traverse from right to left, from bottom to top, from the middle to the right (or left), such as the "palindrome" problems. Sometimes, it is necessary to traverse a line twice, first forward and then backward.
- - When the order is determined correctly, the starting point is determined. Starting from the starting point, fill in the `dp` grid data "in order". This order is also the order in which the program processes.
- - In this process, you will get inspiration to write a "recursive formula". If you can already derive the formula, you do not need to complete the grid.
-4. Based on the `dp` grid data, derive the **recursive formula**.
- - There are three special positions to pay attention to: `dp[i - 1][j - 1]`, `dp[i - 1][j]` and `dp[i][j - 1]`, the current `dp[i][j]` often depends on them.
- - When operating "two swappable arrays", due to symmetry, we may need to use `dp[i - 1][j]` and `dp[i][j - 1]` at the same time.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
- - Focus on analyzing those values that are not as expected.
-
-After reading the above, do you feel that "dynamic programming" is not that difficult? Try to solve this problem. 🤗
-
-## Step-by-Step Solution
-
-1. Determine the **meaning** of the `dp[i]`
- - Imagine that `dp[i]` represents the `largest sum` at index `i`. Is this okay?
- mark-detail `dp[i + 1]` cannot be calculated by `dp[i]`. So we have to change the meaning. mark-detail
-- How to design it?
- mark-detail If `dp[i]` represents the `current sum` at index `i`, `dp[i + 1]` can be calculated by `dp[i]`. Finally, we can see that the `maximum sum` is recorded in the `current sum` array. mark-detail
-2. Determine the `dp` array's initial value
-
- ```ruby
- nums = [-2, 1, -3, 4, -1, 2, 1, -5, 4]
- dp = [-2, 1, -3, 4, -1, 2, 1, -5, 4]
- ```
-3. Fill in the `dp` grid data "in order" according to an example.
-
- ```ruby
- nums = [-2, 1, -3, 4, -1, 2, 1, -5, 4]
- dp = [-2, 1, N, N, N, N, N, N, N] # N means don't pay attention to it now
- dp = [-2, 1, -2, N, N, N, N, N, N]
- dp = [-2, 1, -2, 4, N, N, N, N, N]
- dp = [-2, 1, -2, 4, 3, N, N, N, N]
- dp = [-2, 1, -2, 4, 3, 5, N, N, N]
- dp = [-2, 1, -2, 4, 3, 5, 6, N, N]
- dp = [-2, 1, -2, 4, 3, 5, 6, 1, N]
- dp = [-2, 1, -2, 4, 3, 5, 6, 1, 5]
- ```
-4. Based on the `dp` grid data, derive the "recursive formula".
-
- ```python
- dp[i] = max(nums[i], dp[i - 1] + nums[i])
- ```
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
-
-## Complexity
-
-- Time complexity: `O(n)`.
-- Space complexity: `O(n)`.
-
-## Python
-
-```python
-class Solution:
- def maxSubArray(self, nums: List[int]) -> int:
- dp = nums.copy()
-
- for i in range(1, len(dp)):
- dp[i] = max(nums[i], dp[i - 1] + nums[i])
-
- return max(dp)
-```
-
-## Java
-
-```java
-class Solution {
- public int maxSubArray(int[] nums) {
- var dp = nums.clone();
-
- for (var i = 1; i < dp.length; i++) {
- dp[i] = Math.max(nums[i], dp[i - 1] + nums[i]);
- }
-
- return IntStream.of(dp).max().getAsInt(); // if you want to beat 99%, refer to C# soluiton's comment
- }
-}
-```
-
-## JavaScript
-
-```javascript
-var maxSubArray = function (nums) {
- const dp = [...nums]
-
- for (let i = 1; i < dp.length; i++) {
- dp[i] = Math.max(nums[i], dp[i - 1] + nums[i])
- }
-
- return Math.max(...dp)
-};
-```
-
-## Go
-
-```go
-func maxSubArray(nums []int) int {
- dp := slices.Clone(nums)
-
- for i := 1; i < len(nums); i++ {
- dp[i] = max(nums[i], dp[i - 1] + nums[i])
- }
-
- return slices.Max(dp)
-}
-```
-
-## Ruby
-
-```ruby
-def max_sub_array(nums)
- dp = nums.clone
-
- (1...dp.size).each do |i|
- dp[i] = [ nums[i], dp[i - 1] + nums[i] ].max
- end
-
- dp.max
-end
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- public int MaxSubArray(int[] nums)
- {
- var dp = (int[])nums.Clone();
-
- for (var i = 1; i < dp.Length; i++)
- {
- dp[i] = Math.Max(nums[i], dp[i - 1] + nums[i]);
- }
-
- return dp.Max(); // if you want to beat 99%, you can use a variable to collect the maximum value: `if (dp[i] > result) result = dp[i];`
- }
-}
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- int maxSubArray(vector& nums) {
- auto dp = nums;
-
- for (auto i = 1; i < dp.size(); i++) {
- dp[i] = max(nums[i], dp[i - 1] + nums[i]);
- }
-
- return *max_element(dp.begin(), dp.end());
- }
-};
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-## Intuition 2
-
-- The "greedy" algorithm solution and the "dynamic programming" algorithm solution for this problem are essentially the same, both are "dynamic programming", but the "greedy" algorithm here changes from using the dp one-dimensional array and then reducing one dimension to using only two variables.
-- The "greedy" algorithm here can be called "rolling variables". Just like "rolling array (one-dimensional)" corresponds to a two-dimensional array, one dimension can be reduced by rolling.
-
-## Complexity
-
-- Time complexity: `O(N)`.
-- Space complexity: `O(1)`.
-
-## Python
-
-```python
-class Solution:
- def maxSubArray(self, nums: List[int]) -> int:
- result = -float('inf')
- pre_sum = 0
-
- for num in nums:
- pre_sum = max(pre_sum + num, num)
- result = max(result, pre_sum)
-
- return result
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- int maxSubArray(vector& nums) {
- int result = INT_MIN;
- int pre_sum = 0;
-
- for (int num : nums) {
- pre_sum = max(pre_sum + num, num);
- result = max(result, pre_sum);
- }
-
- return result;
- }
-};
-```
-
-## Ruby
-
-```ruby
-# @param {Integer[]} nums
-# @return {Integer}
-def max_sub_array(nums)
- result = -Float::INFINITY
- pre_sum = 0
-
- nums.each do |num|
- pre_sum = [pre_sum + num, num].max
- result = [result, pre_sum].max
- end
-
- result
-end
-```
-
-## Go
-
-```go
-func maxSubArray(nums []int) int {
- result := math.MinInt
- preSum := 0
-
- for _, num := range nums {
- preSum = max(preSum + num, num)
- if preSum > result {
- result = preSum
- }
- }
-
- return result
-}
-```
-
-## JavaScript
-
-```javascript
-/**
- * @param {number[]} nums
- * @return {number}
- */
-var maxSubArray = function(nums) {
- let result = -Infinity;
- let preSum = 0;
-
- for (const num of nums) {
- preSum = Math.max(preSum + num, num);
- result = Math.max(result, preSum);
- }
-
- return result;
-};
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- public int MaxSubArray(int[] nums)
- {
- int result = int.MinValue;
- int preSum = 0;
-
- foreach (int num in nums)
- {
- preSum = Math.Max(preSum + num, num);
- result = Math.Max(result, preSum);
- }
-
- return result;
- }
-}
-```
-
-## Java
-
-```java
-class Solution {
- public int maxSubArray(int[] nums) {
- int result = Integer.MIN_VALUE;
- int preSum = 0;
-
- for (int num : nums) {
- preSum = Math.max(preSum + num, num);
- result = Math.max(result, preSum);
- }
-
- return result;
- }
-}
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [53. Maximum Subarray - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/53-maximum-subarray) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/541-reverse-string-ii.md b/en/1-1000/541-reverse-string-ii.md
deleted file mode 100644
index bfe10de..0000000
--- a/en/1-1000/541-reverse-string-ii.md
+++ /dev/null
@@ -1,312 +0,0 @@
-# 541. Reverse String II - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [541. Reverse String II - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/541-reverse-string-ii) for a better experience!
-
-LeetCode link: [541. Reverse String II](https://leetcode.com/problems/reverse-string-ii), difficulty: **Easy**.
-
-## LeetCode description of "541. Reverse String II"
-
-Given a string `s` and an integer `k`, reverse the first `k` characters for every `2k` characters counting from the start of the string.
-
-- If there are fewer than `k` characters left, reverse all of them.
-- If there are less than `2k` but greater than or equal to `k` characters, then reverse the first `k` characters and leave the other as original.
-
-### [Example 1]
-
-**Input**: `s = "abcdefg", k = 2`
-
-**Output**: `bacdfeg`
-
-### [Example 2]
-
-**Input**: `s = "abcd", k = 2`
-
-**Output**: `bacd`
-
-### [Constraints]
-
-- `1 <= s.length <= 10000`
-- `s` consists of only lowercase English letters.
-- `1 <= k <= 10000`
-
-## Intuition
-
-1. The question does not require `reverse in place`, so using a new string `result` as the return value is easier to operate.
-2. In the loop, it is more convenient to use `k` as the step value rather than `2k`, because if `2k` is used, `k` must still be used for judgment.
-3. It is required to reverse only the first `k` characters of each `2k` characters, so a `boolean` variable `should_reverse` is needed as a judgment condition for whether to reverse.
-
-## Step-by-Step Solution
-
-1. Use a new string `result` as the return value. In the loop, the step value is `k`.
-
- ```ruby
- result = ''
- index = 0
-
- while index < s.size
- k_chars = s[index...index + k]
- result += k_chars
- index += k
- end
-
- return result
- ```
-
-2. Use the Boolean variable `should_reverse` as the judgment condition for whether to reverse, and only reverse the first `k` characters of each `2k` characters.
-
- ```ruby
- result = ''
- should_reverse = true # 1
- index = 0
-
- while index < s.size
- k_chars = s[index...index + k]
-
- if should_reverse # 2
- result += k_chars.reverse # 3
- else # 4
- result += k_chars
- end
-
- index += k
- should_reverse = !should_reverse # 5
- end
-
- return result
- ```
-
-## Complexity
-
-- Time complexity: `O(N)`.
-- Space complexity: `O(N)`.
-
-## Python
-
-```python
-class Solution:
- def reverseStr(self, s: str, k: int) -> str:
- result = ''
- should_reverse = True
- index = 0
-
- while index < len(s):
- k_chars = s[index:index + k]
-
- if should_reverse:
- result += k_chars[::-1]
- else:
- result += k_chars
-
- index += k
- should_reverse = not should_reverse
-
- return result
-```
-
-## Java
-
-```java
-class Solution {
- public String reverseStr(String s, int k) {
- var result = new StringBuffer();
- var shouldReverse = true;
- var index = 0;
-
- while (index < s.length()) {
- var kChars = s.substring(index, Math.min(index + k, s.length()));
-
- if (shouldReverse) {
- result.append(new StringBuffer(kChars).reverse());
- } else {
- result.append(kChars);
- }
-
- index += k;
- shouldReverse = !shouldReverse;
- }
-
- return result.toString();
- }
-}
-```
-
-## JavaScript
-
-```javascript
-var reverseStr = function (s, k) {
- let result = ''
- let shouldReverse = true
- let index = 0
-
- while (index < s.length) {
- const kChars = s.substr(index, k)
-
- if (shouldReverse) {
- result += [...kChars].reverse().join('')
- } else {
- result += kChars
- }
-
- index += k
- shouldReverse = !shouldReverse
- }
-
- return result
-};
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- public string ReverseStr(string s, int k)
- {
- string result = "";
- bool shouldReverse = true;
- int index = 0;
-
- while (index < s.Length)
- {
- string kChars = s[index..Math.Min(index + k, s.Length)];
-
- if (shouldReverse)
- {
- result += new string(kChars.Reverse().ToArray());
- }
- else
- {
- result += kChars;
- }
-
- index += k;
- shouldReverse = !shouldReverse;
- }
-
- return result;
- }
-}
-```
-
-## Ruby
-
-```ruby
-def reverse_str(s, k)
- result = ''
- should_reverse = true
- index = 0
-
- while index < s.size
- k_chars = s[index...index + k]
-
- if should_reverse
- result += k_chars.reverse
- else
- result += k_chars
- end
-
- index += k
- should_reverse = !should_reverse
- end
-
- result
-end
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- string reverseStr(string s, int k) {
- string result = "";
- bool shouldReverse = true;
- int index = 0;
-
- while (index < s.length()) {
- auto kChars = s.substr(index, k);
-
- if (shouldReverse) {
- reverse(kChars.begin(), kChars.end());
- }
-
- result += kChars;
- index += k;
- shouldReverse = !shouldReverse;
- }
-
- return result;
- }
-};
-```
-
-## Go
-
-```go
-func reverseStr(s string, k int) string {
- var result []rune
- shouldReverse := true
- index := 0
-
- for index < len(s) {
- end := index + k
- if end > len(s) {
- end = len(s)
- }
- kChars := []rune(s[index:end])
-
- if shouldReverse {
- for i, j := 0, len(kChars) - 1; i < j; i, j = i + 1, j - 1 {
- kChars[i], kChars[j] = kChars[j], kChars[i]
- }
- }
-
- result = append(result, kChars...)
- index += k
- shouldReverse = !shouldReverse
- }
-
- return string(result)
-}
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [541. Reverse String II - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/541-reverse-string-ii) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/58-length-of-last-word.md b/en/1-1000/58-length-of-last-word.md
deleted file mode 100644
index f84f791..0000000
--- a/en/1-1000/58-length-of-last-word.md
+++ /dev/null
@@ -1,260 +0,0 @@
-# 58. Length of Last Word - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [58. Length of Last Word - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/58-length-of-last-word) for a better experience!
-
-LeetCode link: [58. Length of Last Word](https://leetcode.com/problems/length-of-last-word), difficulty: **Easy**.
-
-## LeetCode description of "58. Length of Last Word"
-
-Given a string `s` consisting of words and spaces, return the length of the **last** word in the string.
-
-A **word** is a maximal substring consisting of non-space characters only.
-
-### [Example 1]
-
-**Input**: `s = "Hello World"`
-
-**Output**: `5`
-
-**Explanation**: `The last word is "World" with length 5.`
-
-### [Example 2]
-
-**Input**: `s = " fly me to the moon "`
-
-**Output**: `4`
-
-**Explanation**: `The last word is "moon" with length 4.`
-
-### [Example 3]
-
-**Input**: `s = "luffy is still joyboy"`
-
-**Output**: `6`
-
-**Explanation**: `The last word is "joyboy" with length 6.`
-
-### [Constraints]
-
-- `1 <= s.length <= 10^4`
-- `s` consists of only English letters and spaces `' '`.
-- There will be at least one word in `s`.
-
-## Intuition
-
-- To find the length of the last word, we can use methods like `split()`, `last()`, and `len()`.
-- However, this kind of problem is actually meant to test a programmer’s ability to control `index`.
-- Since the last word is at the end, solving it from the front isn’t very convenient. Is there another way?
-
-Click to view the answer
-You can solve this by traversing the string **backwards**. There are only two cases to consider: whether the current character is a space or not.
-
-* **Initially**, if you encounter a space, skip it and move to the next character. If you encounter a non-space character, increment the `length`.
-* **If `length > 0`**, it means you have already encountered letters. At this point, if the current character is a space, you can return the result.
-
-
-## Complexity
-
-- Time complexity: `O(N)`.
-- Space complexity: `1`.
-
-## Python
-
-```python
-class Solution:
- def lengthOfLastWord(self, s: str) -> int:
- length = 0
-
- for i in range(len(s) - 1, -1, -1):
- if s[i] == " ":
- if length > 0:
- return length
- continue
-
- length += 1
-
- return length
-```
-
-## Ruby
-
-```ruby
-# @param {String} s
-# @return {Integer}
-def length_of_last_word(s)
- length = 0
-
- (s.size - 1).downto(0) do |i|
- if s[i] == " "
- return length if length > 0
- next
- end
-
- length += 1
- end
-
- length
-end
-```
-
-## Java
-
-```java
-class Solution {
- public int lengthOfLastWord(String s) {
- int length = 0;
-
- for (int i = s.length() - 1; i >= 0; i--) {
- if (s.charAt(i) == ' ') {
- if (length > 0) {
- return length;
- }
- continue;
- }
-
- length++;
- }
-
- return length;
- }
-}
-
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- int lengthOfLastWord(string s) {
- int length = 0;
- int n = s.size();
-
- for (int i = n - 1; i >= 0; i--) {
- if (s[i] == ' ') {
- if (length > 0) {
- return length;
- }
- continue;
- }
-
- length++;
- }
-
- return length;
- }
-};
-```
-
-## C#
-
-```csharp
-public class Solution {
- public int LengthOfLastWord(string s) {
- int length = 0;
-
- for (int i = s.Length - 1; i >= 0; i--) {
- if (s[i] == ' ') {
- if (length > 0) {
- return length;
- }
- continue;
- }
-
- length++;
- }
-
- return length;
- }
-}
-
-```
-
-## JavaScript
-
-```javascript
-/**
- * @param {string} s
- * @return {number}
- */
-var lengthOfLastWord = function (s) {
- let length = 0;
-
- for (let i = s.length - 1; i >= 0; i--) {
- if (s[i] === " ") {
- if (length > 0) {
- return length;
- }
- continue;
- }
-
- length++;
- }
-
- return length;
-};
-
-
-```
-
-## Go
-
-```go
-func lengthOfLastWord(s string) int {
- length := 0
-
- for i := len(s) - 1; i >= 0; i-- {
- if s[i] == ' ' {
- if length > 0 {
- return length
- }
- continue
- }
-
- length++
- }
-
- return length
-}
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [58. Length of Last Word - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/58-length-of-last-word) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/583-delete-operation-for-two-strings.md b/en/1-1000/583-delete-operation-for-two-strings.md
deleted file mode 100644
index 7407c5f..0000000
--- a/en/1-1000/583-delete-operation-for-two-strings.md
+++ /dev/null
@@ -1,365 +0,0 @@
-# 583. Delete Operation for Two Strings - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [583. Delete Operation for Two Strings - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/583-delete-operation-for-two-strings) for a better experience!
-
-LeetCode link: [583. Delete Operation for Two Strings](https://leetcode.com/problems/delete-operation-for-two-strings), difficulty: **Medium**.
-
-## LeetCode description of "583. Delete Operation for Two Strings"
-
-Given two strings `word1` and `word2`, return the **minimum** number of **steps** required to make `word1` and `word2` the same.
-
-In one **step**, you can delete exactly one character in either string.
-
-### [Example 1]
-
-**Input**: `word1 = "sea", word2 = "eat"`
-
-**Output**: `2`
-
-**Explanation**:
-
-You need one step to make "sea" to "ea" and another step to make "eat" to "ea".
-
-
-### [Example 2]
-
-**Input**: `word1 = "leetcode", word2 = "etco"`
-
-**Output**: `4`
-
-### [Constraints]
-
-- `1 <= word1.length, word2.length <= 500`
-- `word1` and `word2` consist of only lowercase English letters.
-
-## Intuition
-
-It is a question of **comparing two strings** which is about dealing with "two swappable arrays".
-After doing similar questions many times, we will form the intuition of using `two-dimensional arrays` for dynamic programming.
-
-## Pattern of "Dynamic Programming"
-
-"Dynamic Programming" requires the use of the `dp` array to store the results. The value of `dp[i][j]` can be converted from its previous (or multiple) values through a formula. Therefore, the value of `dp[i][j]` is derived step by step, and it is related to the previous `dp` record value.
-
-#### "Dynamic programming" is divided into five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
-2. Initialize the value of the array `dp`.
-3. Fill in the `dp` grid data **in order** according to an example.
-4. Based on the `dp` grid data, derive the **recursive formula**.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
-
-#### Detailed description of these five steps
-
-1. Determine the **meaning** of each value of the array `dp`.
- - First determine whether `dp` is a one-dimensional array or a two-dimensional array. A `one-dimensional rolling array` means that the values of the array are overwritten at each iteration. Most of the time, using `one-dimensional rolling array` instead of `two-dimensional array` can simplify the code; but for some problems, such as operating "two swappable arrays", for the sake of ease of understanding, it is better to use `two-dimensional array`.
- - Try to use the meaning of the `return value` required by the problem as the meaning of `dp[i]` (one-dimensional) or `dp[i][j]` (two-dimensional). It works about 60% of the time. If it doesn't work, try other meanings.
- - Try to save more information in the design. Repeated information only needs to be saved once in a `dp[i]`.
- - Use simplified meanings. If the problem can be solved with `boolean value`, don't use `numeric value`.
-2. Initialize the value of the array `dp`. The value of `dp` involves two levels:
- 1. The length of `dp`. Usually: `condition array length plus 1` or `condition array length`.
- 2. The value of `dp[i]` or `dp[i][j]`. `dp[0]` or `dp[0][0]` sometimes requires special treatment.
-3. Fill in the `dp` grid data **in order** according to an example.
- - The "recursive formula" is the core of the "dynamic programming" algorithm. But the "recursive formula" is obscure. If you want to get it, you need to make a table and use data to inspire yourself.
- - If the original example is not good enough, you need to redesign one yourself.
- - According to the example, fill in the `dp` grid data "in order", which is very important because it determines the traversal order of the code.
- - Most of the time, from left to right, from top to bottom. But sometimes it is necessary to traverse from right to left, from bottom to top, from the middle to the right (or left), such as the "palindrome" problems. Sometimes, it is necessary to traverse a line twice, first forward and then backward.
- - When the order is determined correctly, the starting point is determined. Starting from the starting point, fill in the `dp` grid data "in order". This order is also the order in which the program processes.
- - In this process, you will get inspiration to write a "recursive formula". If you can already derive the formula, you do not need to complete the grid.
-4. Based on the `dp` grid data, derive the **recursive formula**.
- - There are three special positions to pay attention to: `dp[i - 1][j - 1]`, `dp[i - 1][j]` and `dp[i][j - 1]`, the current `dp[i][j]` often depends on them.
- - When operating "two swappable arrays", due to symmetry, we may need to use `dp[i - 1][j]` and `dp[i][j - 1]` at the same time.
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
- - Focus on analyzing those values that are not as expected.
-
-After reading the above, do you feel that "dynamic programming" is not that difficult? Try to solve this problem. 🤗
-
-## Step-by-Step Solution
-
-1. Determine the **meaning** of the `dp[i][j]`.
- - `dp[i][j]` represents the **minimum** number of steps required to make `word1`'s first `i` letters and `word2`'s first `j` letters the same.
- - `dp[i][j]` is an integer.
-2. Determine the `dp` array's initial value.
- - Use an example:
-
- ```
- After initialization, the 'dp' array would be:
- # e a t
- # 0 1 2 3 # dp[0]
- # s 1 0 0 0
- # e 2 0 0 0
- # a 3 0 0 0
- ```
- - `dp[0][j] = j`, because `dp[0]` represents the empty string, and the number of steps is just the number of chars to be deleted.
- - `dp[i][0] = i`, the reason is the same as the previous line, just viewed in vertical direction.
-3. Fill in the `dp` grid data "in order" according to an example.
-
- ```
- 1. word1 = "s", word2 = "eat"
- # e a t
- # 0 1 2 3
- # s 1 2 3 4 # dp[1]
- ```
- ```
- 2. word1 = "se", word2 = "eat"
- # e a t
- # 0 1 2 3
- # s 1 2 3 4
- # e 2 1 2 3
- ```
- ```
- 3. word1 = "sea", word2 = "eat"
- # e a t
- # 0 1 2 3
- # s 1 2 3 4
- # e 2 1 2 3
- # a 3 2 1 2
- ```
-4. Based on the `dp` grid data, derive the "recursive formula".
-
- ```python
- if word1[i - 1] == word2[j - 1]
- dp[i][j] = dp[i - 1][j - 1]
- else
- dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + 1
- ```
-5. Write a program and print the `dp` array. If it is not as expected, adjust it.
-
-## Complexity
-
-- Time complexity: `O(N * M)`.
-- Space complexity: `O(N * M)`.
-
-## Java
-
-```java
-class Solution {
- public int minDistance(String word1, String word2) {
- var dp = new int[word1.length() + 1][word2.length() + 1];
- for (var i = 0; i < dp.length; i++) {
- dp[i][0] = i;
- }
- for (var j = 0; j < dp[0].length; j++) {
- dp[0][j] = j;
- }
-
- for (var i = 1; i < dp.length; i++) {
- for (var j = 1; j < dp[0].length; j++) {
- if (word1.charAt(i - 1) == word2.charAt(j - 1)) {
- dp[i][j] = dp[i - 1][j - 1];
- } else {
- dp[i][j] = Math.min(dp[i - 1][j], dp[i][j - 1]) + 1;
- }
- }
- }
-
- return dp[dp.length - 1][dp[0].length - 1];
- }
-}
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- public int MinDistance(string word1, string word2)
- {
- var dp = new int[word1.Length + 1, word2.Length + 1];
-
- for (var i = 0; i < dp.GetLength(0); i++)
- dp[i, 0] = i;
-
- for (var j = 0; j < dp.GetLength(1); j++)
- dp[0, j] = j;
-
- for (var i = 1; i < dp.GetLength(0); i++)
- {
- for (var j = 1; j < dp.GetLength(1); j++)
- {
- if (word1[i - 1] == word2[j - 1])
- {
- dp[i, j] = dp[i - 1, j - 1];
- }
- else
- {
- dp[i, j] = Math.Min(dp[i - 1, j], dp[i, j - 1]) + 1;
- }
- }
- }
-
- return dp[dp.GetUpperBound(0), dp.GetUpperBound(1)];
- }
-}
-```
-
-## Python
-
-```python
-class Solution:
- def minDistance(self, word1: str, word2: str) -> int:
- dp = [[0] * (len(word2) + 1) for _ in range(len(word1) + 1)]
- for i in range(len(dp)):
- dp[i][0] = i
- for j in range(len(dp[0])):
- dp[0][j] = j
-
- for i in range(1, len(dp)):
- for j in range(1, len(dp[0])):
- if word1[i - 1] == word2[j - 1]:
- dp[i][j] = dp[i - 1][j - 1]
- else:
- dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + 1
-
- return dp[-1][-1]
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- int minDistance(string word1, string word2) {
- vector> dp(word1.size() + 1, vector(word2.size() + 1));
- for (auto i = 0; i < dp.size(); i++) {
- dp[i][0] = i;
- }
- for (auto j = 0; j < dp[0].size(); j++) {
- dp[0][j] = j;
- }
-
- for (auto i = 1; i < dp.size(); i++) {
- for (auto j = 1; j < dp[0].size(); j++) {
- if (word1[i - 1] == word2[j - 1]) {
- dp[i][j] = dp[i - 1][j - 1];
- } else {
- dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + 1;
- }
- }
- }
-
- return dp[dp.size() - 1][dp[0].size() - 1];
- }
-};
-```
-
-## JavaScript
-
-```javascript
-var minDistance = function (word1, word2) {
- const dp = Array(word1.length + 1).fill().map(
- () => Array(word2.length + 1).fill(0)
- )
- dp.forEach((_, i) => { dp[i][0] = i })
- dp[0].forEach((_, j) => { dp[0][j] = j })
-
- for (let i = 1; i < dp.length; i++) {
- for (let j = 1; j < dp[0].length; j++) {
- if (word1[i - 1] == word2[j - 1]) {
- dp[i][j] = dp[i - 1][j - 1]
- } else {
- dp[i][j] = Math.min(dp[i - 1][j], dp[i][j - 1]) + 1
- }
- }
- }
-
- return dp.at(-1).at(-1)
-};
-```
-
-## Go
-
-```go
-func minDistance(word1 string, word2 string) int {
- dp := make([][]int, len(word1) + 1)
- for i := range dp {
- dp[i] = make([]int, len(word2) + 1)
- dp[i][0] = i
- }
- for j := range dp[0] {
- dp[0][j] = j
- }
-
- for i := 1; i < len(dp); i++ {
- for j := 1; j < len(dp[0]); j++ {
- if word1[i - 1] == word2[j - 1] {
- dp[i][j] = dp[i - 1][j - 1]
- } else {
- dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + 1
- }
- }
- }
-
- return dp[len(dp) - 1][len(dp[0]) - 1]
-}
-```
-
-## Ruby
-
-```ruby
-def min_distance(word1, word2)
- dp = Array.new(word1.size + 1) do
- Array.new(word2.size + 1, 0)
- end
- dp.each_with_index do |_, i|
- dp[i][0] = i
- end
- dp[0].each_with_index do |_, j|
- dp[0][j] = j
- end
-
- (1...dp.size).each do |i|
- (1...dp[0].size).each do |j|
- dp[i][j] =
- if word1[i - 1] == word2[j - 1]
- dp[i - 1][j - 1]
- else
- [ dp[i - 1][j], dp[i][j - 1] ].min + 1
- end
- end
- end
-
- dp[-1][-1]
-end
-```
-
-## Other languages
-
-```java
-// Welcome to create a PR to complete the code of this language, thanks!
-```
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [583. Delete Operation for Two Strings - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/583-delete-operation-for-two-strings) for a better experience!
-
-GitHub repository: [leetcode-python-java](https://github.com/leetcode-python-java/leetcode-python-java).
-
diff --git a/en/1-1000/59-spiral-matrix-ii.md b/en/1-1000/59-spiral-matrix-ii.md
deleted file mode 100644
index c248fea..0000000
--- a/en/1-1000/59-spiral-matrix-ii.md
+++ /dev/null
@@ -1,444 +0,0 @@
-# 59. Spiral Matrix II - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions
-
-> 🚀 **Level Up Your Developer Identity**
->
-> While mastering algorithms is key, showcasing your talent is what gets you hired.
->
-> We recommend [**leader.me**](https://www.leader.me) — the ultimate all-in-one personal branding platform for programmers.
->
-> **The All-In-One Career Powerhouse:**
-> - 📄 **Resume, Portfolio & Blog:** Integrate your skills, GitHub projects, and writing into one stunning site.
-> - 🌐 **Free Custom Domain:** Bind your own personal domain for free—forever.
-> - ✨ **Premium Subdomains:** Stand out with elite tech handle like `name.leader.me`.
->
-> [**Build Your Programmer Brand at leader.me →**](https://www.leader.me)
-
----
-
-Visit original link: [59. Spiral Matrix II - LeetCode Python/Java/C++/JS/C#/Go/Ruby Solutions](https://leetcode.blog/en/leetcode/59-spiral-matrix-ii) for a better experience!
-
-LeetCode link: [59. Spiral Matrix II](https://leetcode.com/problems/spiral-matrix-ii), difficulty: **Medium**.
-
-## LeetCode description of "59. Spiral Matrix II"
-
-Given a positive integer `n`, generate an `n x n` matrix filled with elements from *1* to *n2* in spiral order.
-
-### [Example 1]
-
-
-
-**Input**: `n = 3`
-
-**Output**: `[[1,2,3],[8,9,4],[7,6,5]]`
-
-### [Example 2]
-
-**Input**: `n = 1`
-
-**Output**: `[[1]]`
-
-### [Constraints]
-
-- `1 <= n <= 20`
-
-## Intuition
-
-- The difficulty of this question lies in how to get the next position of the current position in a two-dimensional array.
-
-- You can write a method `get_increment(i, j)`, which is specifically used to get the change between the next position and the current position.
-
-## Step-by-Step Solution
-
-1. Initialize `increments` and `increment_index`:
-
- ```python
- increments = [(0, 1), (1, 0), (0, -1), (-1, 0)] # (i, j) right, down, left, up
- increment_index = 0
- ```
-
-2. Core logic:
-
- ```python
- while num <= n * n:
- matrix[i][j] = num
- num += 1
-
- increment = get_increment(i, j)
- i += increment[0]
- j += increment[1]
- ```
-
-3. For function `get_increment(i, j)`, it should return a pair like `[0, 1]`. First verify whether the current increment is valid. If not, use the next increment.
-
- ```python
- def get_increment(i, j):
- increment = increments[increment_index]
- i += increment[0]
- j += increment[1]
-
- if (
- i < 0 or i >= len(matrix) or
- j < 0 or j >= len(matrix) or
- matrix[i][j] is not None
- ): # not valid, use next increment
- increment_index += 1
- increment_index %= len(self.increments)
-
- return increments[increment_index]
- ```
-
-## Complexity
-
-- Time complexity: `O(N * N)`.
-- Space complexity: `O(N * N)`.
-
-## Java
-
-```java
-class Solution {
- private int[][] matrix;
- private int[][] increments = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
- private int incrementIndex = 0;
-
- public int[][] generateMatrix(int n) {
- matrix = new int[n][n];
- var i = 0;
- var j = 0;
- var num = 1;
-
- while (num <= n * n) {
- matrix[i][j] = num;
- num++;
-
- var increment = getIncrement(i, j);
- i += increment[0];
- j += increment[1];
- }
-
- return matrix;
- }
-
- private int[] getIncrement(int i, int j) {
- var increment = increments[incrementIndex];
- i += increment[0];
- j += increment[1];
-
- if (
- i < 0 || i >= matrix.length ||
- j < 0 || j >= matrix.length ||
- matrix[i][j] > 0
- ) {
- incrementIndex += 1;
- incrementIndex %= increments.length;
- }
-
- return increments[incrementIndex];
- }
-}
-```
-
-## Python
-
-```python
-class Solution:
- def __init__(self):
- self.matrix = None
- self.increments = [(0, 1), (1, 0), (0, -1), (-1, 0)]
- self.increment_index = 0
-
- def generateMatrix(self, n: int) -> List[List[int]]:
- self.matrix = [[None] * n for _ in range(n)]
- i = 0
- j = 0
- num = 1
-
- while num <= n * n:
- self.matrix[i][j] = num
- num += 1
-
- increment = self.get_increment(i, j)
- i += increment[0]
- j += increment[1]
-
- return self.matrix
-
- def get_increment(self, i, j):
- increment = self.increments[self.increment_index]
- i += increment[0]
- j += increment[1]
-
- if (
- i < 0 or i >= len(self.matrix) or
- j < 0 or j >= len(self.matrix) or
- self.matrix[i][j]
- ):
- self.increment_index += 1
- self.increment_index %= len(self.increments)
-
- return self.increments[self.increment_index]
-```
-
-## JavaScript
-
-```javascript
-let matrix
-const increments = [[0, 1], [1, 0], [0, -1], [-1, 0]]
-let incrementIndex
-
-var generateMatrix = function (n) {
- matrix = Array(n).fill().map(() => Array(n).fill(0))
- incrementIndex = 0
-
- let i = 0
- let j = 0
- let num = 1
-
- while (num <= n * n) {
- matrix[i][j] = num
- num++
-
- const increment = getIncrement(i, j)
- i += increment[0]
- j += increment[1]
- }
-
- return matrix
-};
-
-function getIncrement(i, j) {
- const increment = increments[incrementIndex]
- i += increment[0]
- j += increment[1]
-
- if (
- i < 0 || i >= matrix.length ||
- j < 0 || j >= matrix.length ||
- matrix[i][j] > 0
- ) {
- incrementIndex += 1
- incrementIndex %= increments.length
- }
-
- return increments[incrementIndex]
-}
-```
-
-## C#
-
-```csharp
-public class Solution
-{
- int[][] matrix;
- int[][] increments = { new[] {0, 1}, new[] {1, 0}, new[] {0, -1}, new[] {-1, 0} };
- int incrementIndex = 0;
-
- public int[][] GenerateMatrix(int n)
- {
- matrix = new int[n][];
-
- for (int k = 0; k < n; k++)
- matrix[k] = new int[n];
-
- int i = 0;
- int j = 0;
- int num = 1;
-
- while (num <= n * n)
- {
- matrix[i][j] = num;
- num++;
-
- int[] increment = getIncrement(i, j);
- i += increment[0];
- j += increment[1];
- }
-
- return matrix;
- }
-
- int[] getIncrement(int m, int n)
- {
- int[] increment = increments[incrementIndex];
- int i = m + increment[0];
- int j = n + increment[1];
-
- if (
- i < 0 || i >= matrix.GetLength(0) ||
- j < 0 || j >= matrix.GetLength(0) ||
- matrix[i][j] > 0
- )
- {
- incrementIndex += 1;
- incrementIndex %= increments.Length;
- }
-
- return increments[incrementIndex];
- }
-}
-```
-
-## Ruby
-
-```ruby
-def generate_matrix(n)
- @matrix = Array.new(n) { Array.new(n) }
- @increments = [[0, 1], [1, 0], [0, -1], [-1, 0]]
- @increment_index = 0
-
- i = 0
- j = 0
- num = 1
-
- while num <= n * n
- @matrix[i][j] = num
- num += 1
-
- increment = get_increment(i, j)
- i += increment[0]
- j += increment[1]
- end
-
- @matrix
-end
-
-private
-
-def get_increment(i, j)
- increment = @increments[@increment_index]
- next_i = i + increment[0]
- next_j = j + increment[1]
-
- if next_i < 0 || next_i >= @matrix.size ||
- next_j < 0 || next_j >= @matrix.size ||
- @matrix[next_i][next_j]
- @increment_index += 1
- @increment_index %= @increments.size
- end
-
- @increments[@increment_index]
-end
-```
-
-## Go
-
-```go
-type spiralMatrix struct {
- matrix [][]int
- increments [][2]int
- incrementIndex int
-}
-
-func (sm *spiralMatrix) getIncrement(i, j int) [2]int {
- currentIncrement := sm.increments[sm.incrementIndex]
- nextI := i + currentIncrement[0]
- nextJ := j + currentIncrement[1]
-
- if nextI < 0 || nextI >= len(sm.matrix) ||
- nextJ < 0 || nextJ >= len(sm.matrix) ||
- sm.matrix[nextI][nextJ] != 0 {
- sm.incrementIndex = (sm.incrementIndex + 1) % len(sm.increments)
- }
- return sm.increments[sm.incrementIndex]
-}
-
-func generateMatrix(n int) [][]int {
- sm := &spiralMatrix{
- matrix: make([][]int, n),
- increments: [][2]int{{0, 1}, {1, 0}, {0, -1}, {-1, 0}},
- incrementIndex: 0,
- }
-
- for i := range sm.matrix {
- sm.matrix[i] = make([]int, n)
- }
-
- i, j, num := 0, 0, 1
-
- for num <= n * n {
- sm.matrix[i][j] = num
- num++
-
- increment := sm.getIncrement(i, j)
- i += increment[0]
- j += increment[1]
- }
-
- return sm.matrix
-}
-```
-
-## C++
-
-```cpp
-class Solution {
-public:
- vector> generateMatrix(int n) {
- matrix_ = vector>(n, vector(n, 0));
- increments_ = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
- increment_index_ = 0;
-
- int i = 0;
- int j = 0;
- int num = 1;
-
- while (num <= n * n) {
- matrix_[i][j] = num;
- num++;
-
- vector increment = getIncrement(i, j);
- i += increment[0];
- j += increment[1];
- }
-
- return matrix_;
- }
-
-private:
- vector> matrix_;
- vector> increments_;
- int increment_index_;
-
- vector