Editorial Solution won't work in all cases.....!


#1
If the input is like this ..
5 -> 9 -> 5 -> 5 -> 6 -> 6;
the output will be 
5 -> 9 -> 5 -> 6
So there are 2 5's in the output Since the solution only compares the current element with the next one.. 
To avoid this follow this approach  -->
            List<Integer> nums = new ArrayList<>();
            ListNode temp = A;
            nums.add(A.val);
            while(temp.next!=null){
                if(nums.contains(temp.next.val)){
                    temp.next = temp.next.next;
                }
                else{
                    nums.add(temp.next.val);    
                temp     = temp.next;
                    }
                }
                return A;

#2

The question states that input is sorted .