1. /**
    2. * @Description 没啥说的,就是遍历链表并剔除重复元素
    3. * 卑微的一天从简单题开始
    4. * @Date 2022/1/17 9:54 下午
    5. * @Author wuqichuan@zuoyebang.com
    6. **/
    7. public class Solution {
    8. public ListNode deleteDuplicates(ListNode head) {
    9. ListNode cur = head;
    10. while (cur != null && cur.next != null){
    11. ListNode next = cur.next;
    12. if(cur.val == next.val){
    13. cur.next = next.next;
    14. }else {
    15. cur = cur.next;
    16. }
    17. }
    18. return head;
    19. }
    20. }