¡GoConqr estrena diseño! Cuéntanos qué te parece.

Fichas

Remove Duplicates from a Linked List

Suhas S Inglés 1 ficha

Fichas del conjunto (1)

  1. 1Remove duplicate nodes from linked list of integers while keeping only the first occurrence of duplicates./**
    * Definition for singly-linked list.
    * public class ListNode {
    * int val;
    * ListNode next;
    * ListNode(int x) { val = x; }
    * }
    */
    class Solution {
    public ListNode deleteDuplicates(ListNode head) {
    if(head == null) return head;
    ListNode temp = head;
    while(temp != null ){
    if(temp.next == null){
    break;
    }
    ListNode next = temp.next;
    if(temp.val == next.val){
    temp.next = next.next;
    }else{
    temp = temp.next;
    }
    }
    return head;
    }
    }

Información

Descripción
Fichas sobre Remove Duplicates from a Linked List, creado por Suhas S el 13/02/2018.
Creado por
Suhas S · feb 2018
Actualizado
13 feb 2018
Visitas
6
Etiquetas
linked list
Valoración

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?