Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- public class ListNode {
- int val;
- ListNode next;
- ListNode(int x) {
- val = x;
- }
- public ListNode deleteDuplicates(ListNode head) {
- while (head.next != null) {
- if (head.val == head.next.val) {
- head.next = head.next.next;
- continue;
- }
- head = head.next;
- }
- return null;
- }
- @Override
- public String toString() {
- if (next != null) {
- return val + ", " + next;
- } return val + "";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement