Movatterモバイル変換


[0]ホーム

URL:


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

Commite2b9754

Browse files
authored
tests: add tests ofLongestIncreasingSubsequence (#1660)
1 parentcc1e1dc commite2b9754

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

‎Dynamic-Programming/LongestIncreasingSubsequence.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
// Return the length of the Longest Increasing Subsequence, given array x
77
functionlongestIncreasingSubsequence(x){
88
constlength=x.length
9+
if(length==0){
10+
return0
11+
}
912
constdp=Array(length).fill(1)
1013

1114
letres=1
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import{longestIncreasingSubsequence}from'../LongestIncreasingSubsequence'
2+
3+
describe('Testing longestIncreasingSubsequence',()=>{
4+
it.each([
5+
[[],0],
6+
[[1],1],
7+
[[2,2],1],
8+
[[3,3,3],1],
9+
[[4,4,4,4],1],
10+
[[1,2],2],
11+
[[1,2,2,2,2],2],
12+
[[1,0,2],2],
13+
[[1,10,2,30],3],
14+
[[5,8,3,7,9,1],3],
15+
[[10,9,2,5,3,7,101,18],4],
16+
[[10,10,9,9,2,2,5,5,3,3,7,7,101,101,18,18],4],
17+
[[0,1,0,3,2,3],4],
18+
[[1,1,2,2,2],2],
19+
[[1,1,2,2,2,3,3,3,3],3],
20+
[[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15],6]
21+
])('check with %j',(input,expected)=>{
22+
expect(longestIncreasingSubsequence(input)).toBe(expected)
23+
})
24+
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp