Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a8db870

Browse files
committed
.
1 parent 95866bd commit a8db870

File tree

85 files changed

+237
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+237
-6
lines changed

‎0301-0400/330. Patching Array.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
let n' be the length of the array.
22
greedy. suppose we can form any integer in [0,m) using the first j numbers, let x be the (j+1)-th number. if x<=m, we can expand [0,m) to [0,m)+[x,x+m)=[0,x+m), otherwise greedily add a new number m, and expand to [0,2m). using O(log n) integers are sufficient, so time O(n'+log n).
3+
We can get O(n') using bit tricks.
4+

‎0401-0500/474. Ones and Zeroes.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
let k be the number of strings. 2D knapsack. O(nmk).
1+
1. let k be the number of strings. 2D knapsack. O(nmk).
2+
2. O~(max{n,m}^{8/3}). See my article https://leetcode.cn/problems/ones-and-zeroes/solutions/3041330/geng-kuai-de-omaxnm83de-suan-fa-by-hqztr-nldf/
3+
Remark. faster algorithms for 2D subset sum with maximum cardinality?
4+

‎0601-0700/611. Valid Triangle Number.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ let the range of the numbers be O(U).
22
1. O(n^2) by double pointers, enumerate one number.
33
2. we can reduce this problem to the tripartite version of 259. 3Sum Smaller, wlog assume a[i]<=a[j]<=a[k], can form a triangle iff a[i]+a[j]>a[k], i.e. a[i]+a[j]-a[k]>0. use a counting argument. O(n+U log U).
44

5-
note. is this problem 3sum-hard?
6-
if we allow negative edge weights (which doesn't make sense in geometry), we can reduce the tripartite version of 3sum to the tripartite version of this problem.
5+
note. this problem is 3sum-hard.
6+
1. If we allow negative edge weights (which doesn't make sense in geometry), we can reduce the tripartite version of 3sum to the tripartite version of this problem.
7+
2. We can reduce 3sum to this problem, by first count the number of solutions once, then add each number by eps and count again. If the count differs then there's a 3sum solution.
78

‎0901-1000/980. Unique Paths III.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Hamiltonian path.
1+
Counting Hamiltonian path on grid.
22
1. dfs.
3-
2. state-compressed DP.
3+
2. state-compressed DP using connectivity on the boundary. 2^{O(min{n,m})}.
44

Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
knapsack/subset sum. O~(t^1.5). See my article https://leetcode.cn/problems/length-of-the-longest-subsequence-that-sums-to-target/solutions/3041311/geng-kuai-de-ot15de-suan-fa-by-hqztrue-47yj/
2+
Remark. better algorithm?
3+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
O(L).
2+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Consider the rows and cols separately. O(sort(hBars.length+vBars.length)).
2+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DP. Let f[i] denote the optimal cost to buy items i~n. monotone queue. O(n).
2+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
O(nm).
2+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /