Skip to content

Commit d10a54b

Browse files
authored
Improved tasks 173, 209
1 parent 3e6bea5 commit d10a54b

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

src/main/ts/g0101_0200/s0173_binary_search_tree_iterator/solution.ts

+17-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// #Data_Structure_II_Day_17_Tree #Programming_Skills_II_Day_16 #Level_2_Day_9_Binary_Search_Tree
33
// #Top_Interview_150_Binary_Tree_General #2025_04_09_Time_6_ms_(98.16%)_Space_69.76_MB_(29.04%)
44

5-
import { TreeNode } from "../../com_github_leetcode/treenode";
5+
import { TreeNode } from '../../com_github_leetcode/treenode'
66

77
/**
88
* Definition for a binary tree node.
@@ -18,41 +18,41 @@ import { TreeNode } from "../../com_github_leetcode/treenode";
1818
* }
1919
*/
2020
class BSTIterator {
21-
private node: TreeNode | null;
21+
private node: TreeNode | null
2222

2323
constructor(root: TreeNode | null) {
24-
this.node = root;
24+
this.node = root
2525
}
2626

2727
next(): number {
28-
let res = -1;
28+
let res = -1
2929
while (this.node !== null) {
3030
if (this.node.left !== null) {
31-
let rightMost = this.node.left;
31+
let rightMost = this.node.left
3232
while (rightMost.right !== null && rightMost.right !== this.node) {
33-
rightMost = rightMost.right;
33+
rightMost = rightMost.right
3434
}
3535

3636
if (rightMost.right === null) {
37-
rightMost.right = this.node;
38-
this.node = this.node.left;
37+
rightMost.right = this.node
38+
this.node = this.node.left
3939
} else {
40-
rightMost.right = null;
41-
res = this.node.val;
42-
this.node = this.node.right;
43-
return res;
40+
rightMost.right = null
41+
res = this.node.val
42+
this.node = this.node.right
43+
return res
4444
}
4545
} else {
46-
res = this.node.val;
47-
this.node = this.node.right;
48-
return res;
46+
res = this.node.val
47+
this.node = this.node.right
48+
return res
4949
}
5050
}
51-
return res;
51+
return res
5252
}
5353

5454
hasNext(): boolean {
55-
return this.node !== null;
55+
return this.node !== null
5656
}
5757
}
5858

src/test/ts/g0201_0300/s0209_minimum_size_subarray_sum/solution.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { minSubArrayLen } from 'src/main/ts/g0201_0300/s0209_minimum_size_subarr
33
import { expect, test } from 'vitest'
44

55
test('minSubArrayLen', () => {
6-
expect(minSubArrayLen(7, [2,3,1,2,4,3])).toEqual(2)
6+
expect(minSubArrayLen(7, [2, 3, 1, 2, 4, 3])).toEqual(2)
77
})
88

99
test('minSubArrayLen2', () => {
10-
expect(minSubArrayLen(4, [1,4,4])).toEqual(1)
10+
expect(minSubArrayLen(4, [1, 4, 4])).toEqual(1)
1111
})
1212

1313
test('minSubArrayLen3', () => {
14-
expect(minSubArrayLen(11, [1,1,1,1,1,1,1,1])).toEqual(0)
14+
expect(minSubArrayLen(11, [1, 1, 1, 1, 1, 1, 1, 1])).toEqual(0)
1515
})

0 commit comments

Comments
 (0)