Convert min heap to max heap in linear time
Given an array representing a min-heap, convert it into a max-heap. The conversion should be done in-place and in linear time.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven an array representing a min-heap, convert it into a max-heap. The conversion should be done in-place and in linear time.
Given a BST and a positive number k, find the k’th smallest node in it.
Given an integer array, find a subset in it having the maximum product of its elements.
Given two integers, add their binary representation.
Given an unsorted integer array, print all pairs with a given difference k in it.
Given a sorted array containing duplicates, efficiently find each element’s frequency without traversing the whole array.
Given an integer array, determine the index of an element before which all elements are smaller and after which all are greater.
Given an integer array, duplicates are present in it in a way that all duplicates appear an even number of times except one which appears an odd number of times. Find that odd appearing element in linear time and without using any extra memory.
Given an integer array, find the minimum and maximum element present in it by making minimum comparisons by using the divide-and-conquer technique.
Given an unsorted linked list, write a function that deletes any duplicate nodes from the list by traversing it only once.
Given an array where all its elements are sorted except two swapped elements, sort it in linear time. Assume there are no duplicates in the array.
This post covers a variation of counting sort that can work on negative numbers and can sort numbers in any range.