Skip to content

Commit 0dda3d5

Browse files
refactor 99
1 parent 02c6a76 commit 0dda3d5

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

+38-2
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
public class _99 {

0 commit comments

Comments
 (0)