Skip to content

feat: add solutions to lc problem: No.3313 #3623

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lcof2/剑指 Offer II 101. 分割等和子串/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ class Solution {
let target = s / 2
var dp = Array(repeating: false, count: target + 1)
dp[0] = true

for num in nums {
for j in stride(from: target, through: num, by: -1) {
dp[j] = dp[j] || dp[j - num]
}
}

return dp[target]
}
}
Expand Down
8 changes: 4 additions & 4 deletions lcof2/剑指 Offer II 102. 加减的目标值/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ class Solution {
if target < -1000 || target > 1000 {
return 0
}

let n = nums.count
var dp = Array(repeating: Array(repeating: 0, count: 2001), count: n)

dp[0][nums[0] + 1000] += 1
dp[0][-nums[0] + 1000] += 1

for i in 1..<n {
for j in -1000...1000 {
if dp[i - 1][j + 1000] > 0 {
Expand All @@ -186,7 +186,7 @@ class Solution {
}
}
}

return dp[n - 1][target + 1000]
}
}
Expand Down
2 changes: 1 addition & 1 deletion lcof2/剑指 Offer II 105. 岛屿的最大面积/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ class Solution {
var area = 1
grid[i][j] = 0
let dirs = [-1, 0, 1, 0, -1]

for k in 0..<4 {
let x = i + dirs[k], y = j + dirs[k + 1]
if x >= 0 && x < m && y >= 0 && y < n {
Expand Down
2 changes: 1 addition & 1 deletion solution/1400-1499/1436.Destination City/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ tags:

<pre>
<strong>输入:</strong>paths = [["London","New York"],["New York","Lima"],["Lima","Sao Paulo"]]
<strong>输出:</strong>"Sao Paulo"
<strong>输出:</strong>"Sao Paulo"
<strong>解释:</strong>从 "London" 出发,最后抵达终点站 "Sao Paulo" 。本次旅行的路线是 "London" -&gt; "New York" -&gt; "Lima" -&gt; "Sao Paulo" 。
</pre>

Expand Down
2 changes: 1 addition & 1 deletion solution/1400-1499/1436.Destination City/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ tags:

<pre>
<strong>Input:</strong> paths = [[&quot;London&quot;,&quot;New York&quot;],[&quot;New York&quot;,&quot;Lima&quot;],[&quot;Lima&quot;,&quot;Sao Paulo&quot;]]
<strong>Output:</strong> &quot;Sao Paulo&quot;
<strong>Output:</strong> &quot;Sao Paulo&quot;
<strong>Explanation:</strong> Starting at &quot;London&quot; city you will reach &quot;Sao Paulo&quot; city which is the destination city. Your trip consist of: &quot;London&quot; -&gt; &quot;New York&quot; -&gt; &quot;Lima&quot; -&gt; &quot;Sao Paulo&quot;.
</pre>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ tags:
<pre>
<strong>Input:</strong> nums = [9,12,5,10,14,3,10], pivot = 10
<strong>Output:</strong> [9,5,3,10,10,12,14]
<strong>Explanation:</strong>
<strong>Explanation:</strong>
The elements 9, 5, and 3 are less than the pivot so they are on the left side of the array.
The elements 12 and 14 are greater than the pivot so they are on the right side of the array.
The relative ordering of the elements less than and greater than pivot is also maintained. [9, 5, 3] and [12, 14] are the respective orderings.
Expand All @@ -51,7 +51,7 @@ The relative ordering of the elements less than and greater than pivot is also m
<pre>
<strong>Input:</strong> nums = [-3,4,3,2], pivot = 2
<strong>Output:</strong> [-3,2,4,3]
<strong>Explanation:</strong>
<strong>Explanation:</strong>
The element -3 is less than the pivot so it is on the left side of the array.
The elements 4 and 3 are greater than the pivot so they are on the right side of the array.
The relative ordering of the elements less than and greater than pivot is also maintained. [-3] and [4, 3] are the respective orderings.
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading