-
Notifications
You must be signed in to change notification settings - Fork 19
/
Util.java
36 lines (32 loc) · 816 Bytes
/
Util.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
package oj.leetcode;
/**
* @author vonzhou
* @date 2019/1/15
*/
public class Util {
public static void printArr(int[] arr){
if(arr != null){
for(int i=0;i<arr.length;i++){
System.out.print(arr[i] + " ");
}
System.out.println();
}
}
public static void showList(ListNode head) {
ListNode p = head;
while (p != null) {
System.out.print(p.val + " ");
p = p.next;
}
System.out.println();
}
public static ListNode createListFromArray(int[] arr) {
ListNode head = null;
for (int i = arr.length-1; i >= 0; i--) {
ListNode node = new ListNode(arr[i]);
node.next = head;
head = node;
}
return head;
}
}