Find k’th node from the end of a linked list
Given a linked list and a positive integer k, find the k’th node from the end of the list.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven a linked list and a positive integer k, find the k’th node from the end of the list.
Given two linked lists, merge their nodes to make one list, taking nodes alternately between the two lists. If either list runs out, all the nodes should be taken from the other list.
Given a linked list, move its front node in front of another given list.
Given a linked list sorted in increasing order, write a function that removes duplicate nodes from the list by traversing it only once.
Given a list, split it into two sublists – one for the front half and one for the back half. If the total number of elements is odd, the extra element should go in the front list.
Given a sorted list in increasing order and a single node, insert the node into the list’s correct sorted position. The function should take an existing node and rearranges pointers to insert it into the list.
Write a pop() function that is the inverse of push(). The pop() function takes a non-empty list, deletes the head node, and returns the head node’s data.
Write a function that takes a linked list, deallocates all of its memory, and sets its head pointer to NULL (the empty list).
Write a function that takes a singly linked list and returns a complete copy of that list.
Given a positive integer n, count all n–digit binary numbers without any consecutive 1’s.
Given a positive number n, efficiently generate binary numbers between 1 and n using the queue data structure in linear time.
Run–length encoding (RLE) is a simple form of lossless data compression that runs on sequences with the same value occurring many consecutive times. It encodes the sequence to store only a single value and its count.