forked from DreamCats/java-notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
41 lines (33 loc) · 756 Bytes
/
Main.java
File metadata and controls
41 lines (33 loc) · 756 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
38
39
40
41
class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode(int x){val = x;}
}
class ListNode {
int val;
ListNode next;
public ListNode(int val) {
this.val = val;
}
}
class ListNodeTools {
public static ListNode getListNode(int[] nums) {
ListNode dummy = new ListNode(-1);
ListNode pre = dummy;
for (int num : nums) {
pre.next = new ListNode(num);
pre = pre.next;
}
return dummy.next;
}
public static void printListNode(ListNode node) {
String s = "";
ListNode p = node;
while (p != null) {
s += p.val + "->";
p = p.next;
}
System.out.println(s+"null");
}
}