File tree Expand file tree Collapse file tree 3 files changed +23
-6
lines changed
append-k-integers-with-minimal-sum
check-if-two-string-arrays-are-equivalent Expand file tree Collapse file tree 3 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ Step 2. Add the dependency
45
45
46
46
<summary >展开查看</summary >
47
47
48
+ https://leetcode.cn/problems/append-k-integers-with-minimal-sum/
49
+
48
50
https://leetcode.cn/problems/inorder-successor-in-bst-ii/
49
51
50
52
https://leetcode.cn/problems/check-if-two-string-arrays-are-equivalent/
Original file line number Diff line number Diff line change
1
+ export default function minimalKSum ( nums : number [ ] , k : number ) : number {
2
+ nums = [ ...new Set ( nums ) ] . sort ( ( a , b ) => a - b ) ;
3
+ const n : number = nums . length ;
4
+ let exist : number = 0 ;
5
+ for ( let i : number = 0 ; i < n ; i ++ ) {
6
+ if ( nums [ i ] <= k ) {
7
+ k ++ ;
8
+ exist += nums [ i ] ;
9
+ } else {
10
+ break ;
11
+ }
12
+ }
13
+
14
+ return k * ( k + 1 ) / 2 - exist ;
15
+ }
Original file line number Diff line number Diff line change 1
- export default function arrayStringsAreEqual (
2
- word1 : string [ ] ,
3
- word2 : string [ ] ,
4
- ) : boolean {
5
- return word1 . join ( "" ) === word2 . join ( "" ) ;
6
- }
1
+ export default function arrayStringsAreEqual (
2
+ word1 : string [ ] ,
3
+ word2 : string [ ] ,
4
+ ) : boolean {
5
+ return word1 . join ( "" ) === word2 . join ( "" ) ;
6
+ }
You can’t perform that action at this time.
0 commit comments