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

Commit0dda3d5

Browse files
refactor 99
1 parent02c6a76 commit0dda3d5

File tree

1 file changed

+38
-2
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+38
-2
lines changed

‎src/main/java/com/fishercoder/solutions/_99.java

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,44 @@
77
* Two elements of a binary search tree (BST) are swapped by mistake.
88
* Recover the tree without changing its structure.
99
10-
Note:
11-
A solution using O(n) space is pretty straight forward. Could you devise a constant space solution?
10+
Example 1:
11+
12+
Input: [1,3,null,null,2]
13+
14+
1
15+
/
16+
3
17+
\
18+
2
19+
20+
Output: [3,1,null,null,2]
21+
22+
3
23+
/
24+
1
25+
\
26+
2
27+
Example 2:
28+
29+
Input: [3,1,4,null,null,2]
30+
31+
3
32+
/ \
33+
1 4
34+
/
35+
2
36+
37+
Output: [2,1,4,null,null,3]
38+
39+
2
40+
/ \
41+
1 4
42+
/
43+
3
44+
45+
Follow up:
46+
A solution using O(n) space is pretty straight forward.
47+
Could you devise a constant space solution?
1248
*/
1349

1450
publicclass_99 {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp