[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/feixiangcode/algorithm/master/Week_01/id_13/LeetCode_83_13.java [Back]  [Original]

package leetCode;

/**
 * Definition for singly-linked list.
 * public class ListNode {
 * int val;
 * ListNode next;
 * ListNode(int x) { val = x; }
 * }
 */

public class LeetCode_83_13 {

    public ListNode deleteDuplicates(ListNode head) {

        ListNode cur = head;

        while (cur.next != null) {
            if (cur.val == cur.next.val) {
                cur.next = cur.next.next;
            } else {
                cur = cur.next;
            }
        }

        return head;
    }

    public class ListNode {
        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
        }
    }

}

Web Proxy Viewer  |  New URL  |  Original Page