-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTreeNode.java
More file actions
executable file
·37 lines (29 loc) · 933 Bytes
/
Copy pathTreeNode.java
File metadata and controls
executable file
·37 lines (29 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package code.coder.lee.common;
import apple.laf.JRSUIUtils;
/**
* Created by bcc on 16/3/12.
*/
public class TreeNode {
public int val;
public TreeNode left;
public TreeNode right;
public TreeNode(int val) {
this.val = val;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TreeNode treeNode = (TreeNode) o;
if (val != treeNode.val) return false;
if (left != null ? !left.equals(treeNode.left) : treeNode.left != null) return false;
return right != null ? right.equals(treeNode.right) : treeNode.right == null;
}
@Override
public int hashCode() {
int result = val;
result = 31 * result + (left != null ? left.hashCode() : 0);
result = 31 * result + (right != null ? right.hashCode() : 0);
return result;
}
}