Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 0635a77

Browse files
aQuaaQua
aQua
authored and
aQua
committed
673 wrong answer
1 parent e2ba356 commit 0635a77

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed
Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
package Problem0673
22

3-
func findNumberOfLIS(nums []int) int {
4-
res := 0
3+
func findNumberOfLIS(a []int) int {
4+
size := len(a)
5+
rec := make([]int, 0, size)
56

6-
return res
7+
for _, n := range a {
8+
isUsed := false
9+
for i := range rec {
10+
if rec[i] < n {
11+
rec[i] = n
12+
isUsed = true
13+
}
14+
}
15+
if !isUsed {
16+
rec = append(rec, n)
17+
}
18+
}
19+
20+
return len(rec)
721
}

Algorithms/0673.number-of-longest-increasing-subsequence/number-of-longest-increasing-subsequence_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ var tcs = []struct {
1818
2,
1919
},
2020

21+
{
22+
[]int{1, 2, 4, 3, 5, 4, 7, 2},
23+
3,
24+
},
25+
2126
{
2227
[]int{2, 2, 2, 2, 2},
2328
5,

0 commit comments

Comments
 (0)