“Daftar Tertaut Terbalik” Kode Jawaban

Daftar Tertaut Terbalik

 public ListNode ReverseList(ListNode head) 
 {
   if(head==null || head.next == null)
   	return head;

  var t = ReverseList(head.next);
  head.next.next = head;
  head.next = null;

  return t;
}
PrashantUnity

Membalikkan daftar tertaut

void reverse()
	{
		node* current, * prev, * temp;
		current = head;
		prev = NULL;
		while (current != NULL)
		{
			temp = current->next;
			current->next = prev;
			prev = current;
			current = temp;
		}
		head = prev;
	}
ANISH SINGH

Jawaban yang mirip dengan “Daftar Tertaut Terbalik”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya