public static SingleListNode CreateSingleListedListByArray(int[] elements) { if (elements == null) { return(null); } SingleListNode ptr = new SingleListNode(elements[0]); SingleListNode head = ptr; for (int i = 1; i < elements.Length; i++) { ptr.next = new SingleListNode(elements[i]); ptr = ptr.next; } return(head); }
public SingleListNode(int x) { val = x; next = null; }