forked from oleg-cherednik/DailyCodingProblem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolution.java
44 lines (35 loc) · 978 Bytes
/
Solution.java
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
38
39
40
41
42
43
44
import java.util.concurrent.atomic.AtomicInteger;
/**
* @author Oleg Cherednik
* @since 09.03.2020
*/
public class Solution {
public static void main(String... args) {
Node root = generate();
System.out.println(root.val());
System.out.println(root.left().val());
System.out.println(root.right().val());
}
public static Node generate() {
return new Node();
}
public static final class Node {
private static final AtomicInteger COUNT = new AtomicInteger();
private final int val = COUNT.incrementAndGet();
private Node left;
private Node right;
public int val() {
return val;
}
public Node left() {
if (left == null)
left = new Node();
return left;
}
public Node right() {
if (right == null)
right = new Node();
return right;
}
}
}