Split nodes of a linked list into the front and back halves
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.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven 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.
Given a string, in-place remove all occurrences of AB and C from it. For example, for the input string is ‘CBAABCAB’, the string after removal of ‘AB’ and ‘C’ is ‘BA’.
Find all interleavings of given strings that can be formed from all the characters of the first and second string where the order of characters is preserved.
Given two strings, determine if they are anagrams or not. Two strings X and Y are anagrams if by rearranging the letters of X, we can get Y using all the original letters of X exactly once.
Check if a given string can be derived from another string by circularly rotating it. The rotation can be in a clockwise or anti-clockwise rotation.