Empleador activo
Reverse a linked list.
Anónimo
Node ReverseLinkedList(Node head) { Node next = head.next; if (next == null) { return head; } Node revList = ReverseLinkedList(head.next); next.next = head; head.next = null; return revList; }
A recursive approach if anyone is interested. Only works for singly linked/non circular atm. called like: reverse(head, null); public static ListNode reverse(ListNode curr, ListNode prev) { if (curr == null) { return prev; } else { ListNode temp = curr.next; curr.next = prev; prev = curr; return reverse(temp, prev); } }
public static Node reverse(Node n) { if(n != null) { Node reversed.data = n.data; while(n.next != null) { Node insert; insert.data = n.next; insert.next = reversed; reversed = insert; n = n.next; } return reversed; } return null; }
Sigue a tus empresas favoritas para estar al tanto de las últimas oportunidades y disponer de información desde adentro.
Recibe recomendaciones y actualizaciones personalizadas al iniciar tu búsqueda.