File tree Expand file tree Collapse file tree 2 files changed +93
-0
lines changed Expand file tree Collapse file tree 2 files changed +93
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .blankj .easy ._053 ;
2
+
3
+ /**
4
+ * Description:
5
+ * Copyright: Copyright (c) 2012
6
+ * Company: keruyun Technology(Beijing) Chengdu Co. Ltd.
7
+ *
8
+ * @author huangjk
9
+ * @version 1.0 2020/4/3
10
+ */
11
+ public class Kuai_shou_test {
12
+ public static void main (String [] args ) {
13
+ String a = "abc" ;
14
+ for (int i =0 ;i <a .length ();i ++){
15
+ System .out .println (a .charAt (i ));
16
+ System .out .println ((int )a .charAt (i ));
17
+ }
18
+ System .out .println (Integer .MAX_VALUE );
19
+ }
20
+
21
+ public int count (int [][] a ,int x ,int y ){
22
+
23
+ return 1 ;
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ package com .blankj .myself ;
2
+
3
+ import java .util .Objects ;
4
+ import java .util .Stack ;
5
+
6
+ /**
7
+ * Description:
8
+ * Copyright: Copyright (c) 2012
9
+ * Company: keruyun Technology(Beijing) Chengdu Co. Ltd.
10
+ *
11
+ * @author huangjk
12
+ * @version 1.0 2020/5/18
13
+ */
14
+
15
+ public class TreePostNode {
16
+
17
+ public static void main (String [] args ) {
18
+
19
+ }
20
+
21
+ public TreeNode inorderSuccessor (TreeNode root , TreeNode p ) {
22
+ Stack <TreeNode > stack = new Stack <>();
23
+ TreeNode result = null ;
24
+ if (Objects .nonNull (p .right )){
25
+ result = p .right ;
26
+ while (Objects .nonNull (result .left )){
27
+ result = result .left ;
28
+ }
29
+ }else {
30
+ stack .add (root );
31
+ TreeNode temp = root ;
32
+ Boolean findFlag = false ;
33
+ while (!findFlag ){
34
+ if (p .val >temp .val ){
35
+ temp = temp .right ;
36
+ stack .add (temp );
37
+
38
+ }else if (p .val <temp .val ){
39
+ temp = temp .left ;
40
+ stack .add (temp );
41
+
42
+ }else {
43
+ findFlag = true ;
44
+ }
45
+ }
46
+ findFlag = false ;
47
+ TreeNode child = p ;
48
+ while (stack .size ()>0 &&!findFlag ){
49
+ TreeNode parent = stack .pop ();
50
+ if (child == parent .left ){
51
+ result = parent ;
52
+ findFlag = true ;
53
+ }else {
54
+ child = parent ;
55
+ }
56
+ }
57
+
58
+ }
59
+ return result ;
60
+ }
61
+
62
+ public class TreeNode {
63
+ int val ;
64
+ TreeNode left ;
65
+ TreeNode right ;
66
+ TreeNode (int x ) { val = x ; }
67
+ }
68
+ }
You can’t perform that action at this time.
0 commit comments