Tags » Linked List

Remove duplicates from a linked list

Assumptions:

  • unsorted
  • non-circular
  • singly linked list

Input/Output:

Input: [ 3 ] -> [ 2 ] -> [ 1 ] -> [ 2 ] -> [ 1 ] -> [ 5 ] -> [ 2 ] -> [ 4 ] -> [ 3 ] -> [ 4 ] 68 more words

Algorithm

Merge k Sorted Lists

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.

Problem link

Solution

  • using a priority queue to keep the organize the k current candidates…
  • 130 more words
Algorithm

Copy List with Random Pointer

A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. 187 more words

Algorithm

Remove Duplicates from Sorted List II

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.

For example,
Given 1->2->3->3->4->4->5, return… 129 more words

Algorithm

Reverse Nodes in k-Group

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.

If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is. 194 more words

Algorithm