Crack The Coding Interview (DSA Sheet)

===============================
Arrays Questions
===============================

Arrays: Given an array of integers in ascending order, return index of the two numbers such that they add up to a specific key provided. 

Arrays: Sort an array of 0s, 1s and 2s in C 

Arrays: Given an array, the difference between the elements is one, find if the “key” element is present or not. 

Arrays: Given an unsorted array, find the minimum difference between 2 elements. 

Arrays: Given an unsorted array, find the least difference between the element pairs. Display all the pairs present. 

Arrays: Given an unsorted array, and a key. Find 2 elements such that the difference between the elements is equal to the key. 

Arrays: Given an unsorted integer array, find the smallest missing positive integer. 

Arrays: Given an array, find all the repeated elements in C language.

Arrays: Given an integer value, convert it into roman number.

Arrays: Given a string, and number of rows, write the string in zigzag pattern. 

Arrays: Find the Container with Most Water explanation with diagram and solution 

Arrays: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.

Arrays: Given a collection of candidate numbers and a key, find all unique combinations in candidates where the candidate numbers sums to target.

Arrays: Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.

Arrays: Given a collection of numbers that might contain duplicates, return all possible unique permutations in C++

Arrays: Given an array of non-negative integers determine if you are able to reach the last index in C++

Arrays: Merge Intervals in C++

Arrays: Jump Game II in CPP

Arrays: Sort Colors In Place

Arrays: Given two integers n and k, return all possible combinations of k numbers out of 1 … n.

Arrays: Given a set of distinct integers, nums, return all possible subsets (the power set).

Arrays: Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length.

Arrays: Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.

Arrays: Insert Interval

Arrays: Given a non-negative integer numRows, generate the first numRows of Pascal’s triangle.

Arrays: Pascal’s triangle 2

Arrays: Given a triangle, find the minimum path sum from top to bottom.

Arrays: Best time to buy sell stock

Arrays: Given a non-empty array of integers, every element appears twice except for one. Find that single one.

Arrays: Given an integer array, find the maximum product made from continuous elements in that array. Solution in C++

Arrays: Find the minimum element from an array that is sorted and is rotated, solution in C++

Arrays: Given an array, find the majority element, solution in C++

Arrays: Given an array and a key element, find the number of continuous elements whose sum is greater than the key element.

Arrays: Given the heights of histogram using an array, you need to find the largest area rectangle in that histogram. Solution in C++

Arrays: You are given an unsorted array, and a key number, find the largest number of that key position.

Arrays: Given an array, that has zero. Move all the zero at the end, but maintain the relative order of other elements.

Arrays: Find the k’th smallest/largest element in an array

Arrays: Move all the negative number in beginning

Arrays: Find the union and intersection of two sorted arrays

Arrays: Given an array, rotate it one time

Arrays: Minimize the maximum difference between the heights

Arrays: Merge Two Sorted arrays without using extra space

Arrays: Inversion Count in an Array

Arrays: Find common element in 3 sorted arrays.

Arrays: Rearrange the array with one positive and one negative number.

Arrays: Find whether an array is subset of another array

Arrays: Find a triplet that sum to a given value

Arrays: Three way partitioning of an array around a given range

Arrays: Find the median of 2 sorted arrays of same size

Arrays: Merge sorted array inplace

Arrays: Find triplet with minimum sum

Arrays: Program to check if an Array is Palindrome or not

Arrays: Check if 3 consecutive odds exist

Arrays: Check If N and Its Double Exist

Arrays: Find unique numbers that sum upto zero

Arrays: Find numbers with even number of digits

Arrays: Product of array except itself

Arrays: Given a sorted array return the absolute distinct count.

Arrays: Create a data structure for n elements and constant operations

Arrays: Cell state after K days

Arrays: Find the minimum number to an array so the sum becomes even

Arrays: Convert an array into permutation of numbers from 1 to N.

Arrays: Given an array and a number n, rotate the array by n steps to its right.

Arrays: Print in a Circular Array

Arrays: Find the closest greater element for every array element from another array

Arrays: Given an array, find minimum number of swaps required to sort the array

Arrays: Given an array, find the minimum operations to make binary array to one

Arrays: Given an array, move all the negative number to the end by preserving the relative order.

Arrays: Get minimum number of moves to sort an array

Arrays: Given a string, reverse all the vowels in the string

Arrays: Given an array, check if it has any duplicate elements, 2 solutions

Arrays: Given an array, and value K find the k th distinct element among unique elements in an array

Arrays: Given a sorted array, find the starting and ending index that matches the target

Arrays: Given an array that is sorted and a target, if the target is found, return the index. If not found, return the index where it would be if it were inserted

Arrays: Given a string, reverse the string.

Arrays: Implement prefix sum array

 

===============================
Strings Questions
===============================

Strings: Group Anagrams in C++

Strings: Wildcard Matching

Strings: Simplify Path CPP

Strings: Given a 2D board and a word, find if the word exists in the grid.

Strings: check if the given string is valid or not explanation with solution

Strings: Decode Ways

Strings: Restore IP Addresses

Strings: Word Ladder

Strings: Given a string s, partition s such that every substring of the partition is a palindrome.

Strings: Given a sentence and maxWidth. Arrange the text in such a way that each line has exactly maxWidth characters and is fully justified.

Strings: You are given a sentence, reverse the string word by word

Strings: Given 2 strings, check if they are isomorphic strings.

Strings: You are given a string that contain a basic expression, calculate the result. Solution in C++.

Strings: Reverse a string

Strings: Print all the duplicates in a string

Strings: Program to check if strings are rotations of each other or not

Strings: Longest Repeating Subsequence

Strings: Given a string, print all the subsequence

Strings: Permutations of a given string

Strings: Divide binary string into sub strings with equal number of 0s and 1s.

Strings: Check balanced parenthesis

Strings: Word Break Problem

Strings: Convert a string into its mobile numeric keypad

Strings: Get the minimum number of inversions needed to make an expression balanced

Strings: Count the number of string in 2D character array

Strings: Convert Roman Numerals to Decimal

Strings: Longest Common Prefix

Strings: Minimum number of flips to make binary string alternate

Strings: Find the first repeated word in a string

Strings: Minimum swaps required for bracket balancing

Strings: Find the longest common subsequence between two strings.

Strings: Check if it is possible to re-arrange characters in a string, such a way that no two adjacent are same

Strings: Minimum characters to be added at beginning to make string palindrome

Strings: Remove all consecutive duplicates from the string

Strings: Find minimum operations required to transform a string into another string

Strings: Recursively print all sentences that can be formed from list of word lists

Strings: Remove all consecutive duplicates from the string

Strings: Given a string convert into its equivalent ASCII form

Strings: Second most repeated word in a sequence

Strings: Convert Postfix to Infix

Strings: Longest Prefix Suffix

Strings: Calculate the basic arithmetic expression as string

Strings: Calculate an expression with * and /

Strings: Given an encoded string, decode string

Strings: Number of Different Integers in a String

Strings: Longest Substring Of All Vowels in Order

Strings: Minimum Number of Swaps to Make the Binary String Alternating

Strings: Longer Contiguous Segments of Ones than Zeros

Strings: Check if Word Equals Summation of Two Words

 

===============================
BitMagic Questions
===============================

Bitwise Operators: Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator.

Bitwise Operators: The gray code is a binary numeral system where two successive values differ in only one bit.

Bitwise Operators: Reverse Bits

Bitwise Operators: Count the number of set bits

Bitwise Operators: Power of 2

Bitwise Operators: Missing Number

Bitwise Operators: Counting set bits in a number

Bitwise Operators: Hamming Distance

Bitwise Operators: Bitwise and of number range

Bitwise Operators: Find the two non repeating numbers.

Bitwise Operators: Count number of bits to be flipped to convert A to B

Bitwise Operators: Bitwise Set bit questions

Bitwise Operators: Copy set bits in a range

Bitwise Operators: Power Set

Bitwise Operators: Given a binary number, return the 1’s and 2’s complement of that number

Bitwise Operators: Add and subtract 2 numbers using bitwise operators.

Bitwise Operators: Calculate the square of a number and also check if that number is even or odd using bitwise operator.

Bitwise Operators: Check if the number has bits in alternate pattern and also check if the same number has equal number of set and unset bits using bitwise operators

Bitwise Operators: Given 2 numbers check if one number is complement of another and also check if those two numbers are same using bitwise operators

Bitwise Operators: Perform below operations using Bitwise Operators

Bitwise Operators: Perform below swapping operations using Bitwise operators

Bitwise Operators: Perform multiplication operation using Bitwise operators

Bitwise Operators: Print the numbers without consecutive 1s in binary representation

Bitwise Operators: Add 1 to a given number

Bitwise Operators: Program to reverse the bits of a number

Bitwise Operators: Given a number, check if the number in its binary representation is palindrome

Bitwise Operators: Print the binary representation of a given number.

Bitwise Operators: Given 2 integers, perform bitwise recursive addition of integers

Bitwise Operators: Toggle all even bits of a number

Bitwise Operators: Given a number “n”, calculate xor of 1 to n

Bitwise Operators: Given a binary string, check the divisibility of the string by 2^k

Bitwise Operators: Check if the given number is sparse or not

Bitwise Operators: Given a number, check if all the bits of the number are set

Bitwise Operators: Given a number, check if the number has same set and unset bits.

Bitwise Operators: Given a number, check if it has 2 adjacent set bits

Bitwise Operators: Bitwise AND of all even number from 1 to N

Bitwise Operators: Given a number, check if it is divisible by 8

Bitwise Operators: Bitwise Operations Tricks

 

===============================
Linked List Questions
===============================

Linked List: Given two non empty Linked List with non negative numbers, and numbers are stored in reverse order having single digit. Add the two list and return the result as a linked list. 

Linked List: Remove Nth Node from End of List 

Linked List: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.

Linked List: Swap Nodes in Pairs solution in C

Linked List: Merge k sorted linked lists and return it as one sorted list in C++

Linked List: Reverse Linked List iterative and recursive in C++

Linked List: Intersection of Two Linked Lists in c++

Linked List: Rotate linked list by k nodes

Linked List: Remove Duplicates from Sorted List solution in CPP

Linked List: Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.

Linked List: Reverse a linked list from position m to n. Do it in one-pass.

Linked List: Given a linked list, determine if it has a cycle in it.

Linked List: Reorder list in to alternate nodes like first lowest and first highest.

Linked List: Sort a linked list using insertion sort.

Linked List: Given an unsorted linked list, sort the list using merge sort.

Linked List: Given a linked list, check if it is a palindrome or not. Solution in C++

Linked List: Reverse Linked List in groups

Linked List: Remove duplicates from an unsorted linked list

Linked List: Move last element to front of a given Linked List

Linked List: Add 1 to the linked list

Linked List: Find middle element in Linked List

Linked List: Split circular Linked List into two halves

Linked List: Program to Check if a Singly Linked List is Palindrome

Linked List: Deletion from a Circular Linked List

Linked List: Reverse a Doubly Linked List

Linked List: Find pairs with a given sum in a DLL.

Linked List: Count triplets in a sorted DLL whose sum is equal to given value “k”.

Linked List: Sort a “k”sorted Doubly Linked list

Linked List: Rotate Doubly linked list by N nodes

Linked List: Rotate a Doubly Linked list in group of Given Size

Linked List: Flatten a Linked List

Linked List: Multiply two numbers represented by Linked Lists

Linked List: Delete nodes which have a greater value on right side using recursion

Linked List: Segregate even and odd nodes in a Linked List

Linked List: Odd Even Linked List

Linked List: Perform binary search on a singly linked list

Linked List: Perform bubble sort on singly linked list

Linked List: Perform below operations on Circular Singly Linked List:

Linked List: Perform below delete operations from single linked list.

Linked List: Perform below delete operations from single linked list.

Linked List: Perform below operations from a circular linked list

Linked List: Given a linked list convert into peak list

Linked List: Perform bubble sort on Double linked list

Linked List: Check if a doubly linked list of characters is palindrome or not

Linked List: Perform the below delete operations on a Doubly Linked List

Linked List: Sort a nearly sorted doubly linked list

Linked List: Split a circular linked list into two halves

Linked List: Copy a linked list with given next and random pointer

Linked List: Given 2 linked list by choosing max element at each position

Linked List: Given a binary tree, convert into circular doubly linked list

Linked List: Convert a single linked list to circular linked list

Linked List: Count the number of rotations in sorted and rotated linked list

Linked List: Given a DLL, delete all the nodes that is greater than the given value

Linked List: Sort a linked list of 0, 1, 2

Linked List: Given a circular linked list, exchange first and last node

Linked List: Find 3 nodes whose sum equal to a given number

Linked List: Given a LL, find the kth node from middle towards the head

Linked List: Given 2 LL, find the first common element

Linked List: Insert node into the middle of the linked list

Linked List: Given Linked list and a value K, partition the list

 

===============================
Stack Questions
===============================

Stack: Given an expression in reverse polish notation, evaluate it and get the output in C++

Stack: C++ program to implement queue using stacks.

Stack: Implement two stacks in an array

Stack: Delete the middle element from the stack.

Stack: Check for balanced brackets using stack

Stack: Next Greater Element

Stack: Evaluate postfix expression

Stack: Insert at the end of stack

Stack: Reverse a stack using recursion

Stack: Sort a stack

Stack: Largest Rectangular Area in a Histogram

Stack: Length of the longest valid substring

Stack: Expression contains redundant bracket or not

Stack: Implement Stack using Queues

Stack: Check if a stack is a permutation of another stack

Stack: Queue Reversal

Stack: Reverse the first “K” elements of a queue

Stack: Next Smaller Element

Stack: Design a stack that returns the minimum element in constant time.

Stack: Get the min element of the stack in O(1) time

Stack: Get the next greater element in a circular array

Stack: Check if given 2 strings are same with backspace character

Stack: Remove outer most redundant parenthesis

Stack: Remove All Adjacent Duplicates In String

Stack: Build an Array With Stack Operations

Stack: Make digit minimum by removing k digits.

Stacks: Minimum Insertions to Balance a Parentheses String

Stacks: Check if the given pattern exist in the array

Stack: Score of Parentheses

Stacks: Validate stack operations

Stack: Convert Infix to Postfix Expression

Stack: Postfix and prefix conversion

Stack: Prefix to infix conversion

Stack: Prefix to postfix conversion

Stack: Nearest smaller numbers on left side in an array

Stack: Given an array, you need to find the previous greater element

Stack: Print Bracket Number

Stack: Reversing the first K elements of a Queue

Stack: Sort a stack using a temporary stack

Stack: Sort a stack using recursion

Stack: Check if stack elements are pairwise consecutive

Stack: Check if the expression contains redundant bracket or not

Stack: Check if a queue can be sorted into another queue using a stack

Stack: Check if an array is stack sortable

Stack: Check if concatenation of two strings is balanced or not

Stack: Check if valid parentheses in an expression

Stack: Merge and sort 2 unsorted array

Stack: Given a string expression, check if it is balanced expression

Stack: Stock Span Problem

Stack: Given 2 arrays, check if an array is stack permutation of another

Stack: Given a string with balanced brackets, you need to print the bracket number

Stack: Delete consecutive same words in a sequence

Stack: Delete middle element of a stack

Stack: Given an expression, get the minimum bracket reversal to make the expression balanced

 

===============================
Searching and Sorting Questions
===============================

Searching and Sorting: Maximum and minimum of an array using minimum number of comparisons

Searching and Sorting: Search an array where adjacent differ by at most k

Searching and Sorting: Count all distinct pairs with difference equal to k

Searching and Sorting: Maximum sum such that no two elements are adjacent

Searching and Sorting: Merge 2 sorted arrays

Searching and Sorting: print all subarrays with 0 sum

Searching and Sorting: Product of array except itself.

Searching and Sorting: Sort Integers by The Number of 1 Bits

Searching and Sorting: Minimum number of swaps required to sort an array

Searching and Sorting: K-th Element of Two Sorted Arrays

Searching and Sorting: Find the missing number in Arithmetic Progression

Searching and Sorting: Factorial Trailing Zeroes

Searching and Sorting: Find the smallest and second smallest elements in an array

Searching and Sorting: Find the majority element in the array

Searching: Find all the triplets with zero sum

Searching: Check the ceiling in a sorted array

Searching: Check if all occurrence if a character appear together

Searching: Get the Pythagorean Triplet in an array

Searching: Check if there exist 2 elements in an array whose sum is equal to the sum of rest of the array

Searching: Given two arrays, generate third array with the given constraints

Searching: Count the number of 1s in a sorted binary array

Searching: Count number of occurrence in a sorted array

Searching: Find median of two sorted array of different sizes

Searching: Allocate minimum pages

Searching: Find fixed point in the given array

Searching: Given an number, find the numbers whose factorials end with n zeros

Searching: Find the closest number in the sorted array

Searching: Find the value and its double in the array

Searching: Given a string and a key, find the smallest letter that is greater than the key

Searching: Given an sorted rotated array, find the given key is present

Searching: Find index of an extra element in a sorted array

Searching: Given an array, find the largest pair sum

Searching: Find the k maximum elements of an array in original array.

Searching: Aggressive Cows

Searching: Find the missing elements of 2 sorted arrays

Searching: Find the missing number

Searching: Given an array, find the first and last position of an element in sorted array

Searching: Given an array, split into n arrays to minimize the maximum sum of all sub arrays

 

===============================
Sorting Questions
===============================

Sorting: Given an array, sort the elements alternatively

Sorting: Get union of 2 sorted arrays

Sorting: Given an array, return the number of steps required to make array elements same

Sorting: Given an array, count inversions

Sorting: Given 2 arrays, return minimum number of platforms required for a railway station

Sorting: Minimum increment to make array unique

Sorting: Merge 2 sorted arrays

Sorting: Check if any interval completely overlaps other

Sorting: Given an array, you need to check if it has contiguous integers

Sorting: Given an array, minimize sum of product of consecutive pairs

Sorting: Check if reversing sub array make the array sorted

Sorting: Check if two arrays are equal or not

Sorting: Check if the array is Arithmetic Progression

Sorting: Check if a given array is K sorted or not

Sorting: Check if the array can be fit into another array by re-arranging the elements.

Sorting: Given an unsorted array and a value x, you need to check if a pair exist for given difference

Sorting: Merge two sorted arrays without extra space.

Sorting: Given a string, sort it by frequency of characters

Sorting: Get the intersection of 2 arrays

Sorting: Sort an array having partially sorted and partially unsorted array

Sorting: Given an array, you need to remove the elements to make the array as sorted.

Sorting: Find minimum difference between any two elements in a array

Sorting: Print elements occurred only once in the array

Sorting: Find the missing element of a range in an array

Sorting: Find a pair with maximum product in array of integers

 

===============================
Binary Searching Questions
===============================

Binary Search: Given an array sorted in ascending order and is rotated at some pivot, given a target value to search, if found in the array return its index

Binary Search: Search a 2D Matrix in C++

Binary Search: Binary search on an array that is in descending order

Binary Search: Order-Agnostic Binary Search

Binary Search: Find the first and last occurrence of an element

Binary Search: Find the number of times a Sorted array is Rotated

Binary Search: Searching in a Nearly Sorted Array

Binary Search: Find Floor of an element in a Sorted Array

Binary Search: Find Ceil of an element in a Sorted Array

Binary Search: Find position of an element in an Infinite Sorted Array

Binary Search: Find the index of first 1 in an infinite sorted array of 0s and 1s

Binary Search: Peak Element

Binary Search: Find maximum element in Bitonic Array

Binary Search: Search An Element in Bitonic Array

Binary Search: Get the rotation count in sorted rotated array

Binary Search: Count the number of 1’s in an array sorted in decreasing order.

Binary Search: Searching and Sorting: Get the fixed point in an array

 

===============================
Queue Questions
===============================

Queue: Given a Linked list, construct a complete binary tree

Queue: Sort a queue without using extra space

Queue: Reverse first K elements in the queue

Queue: Implement priority queue using Linked List

Queue: Find the first non repeating character in the stream

Queue: Given a queue, reverse it

Queue: Given a queue and element k, revert the first k element of the queue

Queue: Implement dequeue using doubly linked list

Queue: Implement queue using stacks

Queue: Given a queue, interleave first half of the queue with second half

Queue: Given a queue, check if queue can be sorted using stack

Queue: Given 2 sorted arrays, you need to merge them using priority queue

Queue: Reverse a stack using queue

Queue: Maximum of all subarrays of size K

 

===============================
Matrix Matrix Questions
===============================

Matrix: You are given an n x n 2D matrix rotate it by 90 degrees (clockwise) in C++.

Matrix: Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.

Matrix: Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order in C++

Matrix: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place.

Matrix: Search a 2D Matrix in C++

Matrix: Check if the given board is valid Sudoku or not explanation with solution in CPP

Matrix: Surrounded Regions

Matrix: Soduku Solver

Matrix: Given a 2d matrix, filled with 1 and 0. Find the maximum sub-matrix that has only 1’s and return the area.

Matrix: Find median in a row wise sorted matrix.

Matrix: Find a row with maximum number of 1’s in a binary matrix

Matrix: Kth smallest element in a sorted matrix

Matrix: Get the common elements in all row of a matrix.

Matrix: Find pair with maximum sum in the matrix.

Matrix: Check if the matrix is Bisymmetric matrix or not

Matrix: Given a matrix, print the boundary elements

Matrix: Given a matrix, check if it is skew symmetric or not

Matrix: Given a matrix, rotate matrix 180 degree

Matrix: Given a matrix, you need to find the sum of diagonals of a matrix.

Matrix: Given a matrix, check if it is a magic square or not

Matrix: Given a matrix, find the transpose of the matrix

Matrix: Given a matrix, check if the matrix is sparse or not

Matrix: Given a matrix, check if all rows of a matrix are circular rotation of each other

Matrix: Given a matrix, check if the sum of ith row and ith column are same

Matrix: Given a matrix, check if it is orthogonal or not

Matrix: Find common elements in all rows of a given matrix

Matrix: Given a matrix, count the number of sorted rows

Matrix: Given a matrix, count the majority element

Matrix: Given a matrix, find the saddle point

Matrix: Given a binary matrix, find the rows with max 1s

Matrix: Given a matrix, you need to count the number of rows and columns whose sum equal to diagonal sum

Matrix: Given a matrix, count zero in row wise and column wise matrix

Matrix: Given a 2D matrix, find the peak element.

Matrix: Given a matrix, set it to zero

 

===============================
Recursion Questions
===============================

Recursion: Count the number of ways a baby can reach the n’th stair taking 1 or 2 steps at a time in C language. 

Recursion: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. 

Recursion: Given a collection of distinct integers, return all possible permutations.

Recursion: Implement pow(x, n), which calculates x raised to the power n (xn) in C++

Recursion: Count the ways to decode a digit sequence

Recursion: Get the nth Fibonacci Number

Recursion: Get the least number of perfect squares

Recursion: Convert a given decimal number into binary using recursion

Recursion: Reverse the queue using recursion

Recursion: Given two numbers, add them recursively

Recursion: Power of three

Recursion: Check if a number is palindrome using recursion

Recursion: Print N to 1 using recursion

Recursion: Print alternate node in a Linked List using recursion

Recursion: Given a string and a sub-string, count the number of occurrence recursively.

Recursion: Given a number, count the number of ways to express a number as sum of powers.

Recursion: Given a decimal number, convert into binary number using recursion

Recursion: Given a stack, delete the middle element using recursion

Recursion: You are given a stack, reverse it using recursion

Recursion: Given a linked list, find the middle element recursively

Recursion: Given a number, generate all binary strings.

Recursion: Given a string, find the occurrence of first uppercase letter in the string.

Recursion: Remove adjacent duplicates in the string.

Recursion: Given an array, generate all sub arrays using recursion

Recursion: Remove K adjacent duplicate in a string

Recursion: Given a number, return the sum of digit

Recursion: Given 2 numbers find the product of the numbers, using recursion

Recursion: Handshake problem

Recursion: Given a number, count the number of set bits using recursion

 

===============================
Heaps Questions
===============================

Heaps: Build Min Heap from an Array

Heaps: Sort an Array using heap

Heaps: Find kth smallest in an unsorted array

Heaps: Merge “K” sorted arrays

Heap: Kth smallest element.

Heap: Return k largest element

Heap: Sort a K sorted array or nearly sorted array

Heap: K closest number

Heap: Top K Frequent Elements

Heap: Frequency sort

Heap: Top K Frequent Words

Heap: Connect ropes with minimum cost

Heap: Sum of all the elements between k1 and k2 smallest elements

Heap: kth largest element in a stream

Heaps Introduction

Heap: Heap Sort

Heap: Max Heap and Min heap using Priority Queue

Heap: Given an array and a value K, return the kth smallest element

Heap: Given two max heaps, merge them

Heap: Given a BST, convert into Min Heap

Heap: Find median in a stream

Heap: Check if given a binary tree is a Heap

Heap: k closest number

Heap: Convert Min Heap to Max Heap

Heap: Given an array, sort the array using min heap

Heap: Given an array, check if the array represents Binary Max Heap

Heap: kth largest in a stream

Heap: Given level order traversal of Binary Tree, check if the tree is Min Heap

Heap: K Closest Points To Origin

Heap: Find the minimum product of k integers in an array

Heap: Given an array, find the kth largest element in the array

Heap: Given an array, find the top K frequency elements

Heap: Given an array, find the kth smallest pair sum

 

===============================
Hashing Questions
===============================

Hashing: Given an array of integers in ascending order, return index of the two numbers such that they add up to a specific key provided. 

Hashing: You are given an array, you need to return kth distinct element

Hashing: Longest consecutive sequence

Hashing: Given an array, check if the array is a permutation of numbers from 1 to N.

Hashing: Given a array, you need to find a duplicate within k distance in the array.

Hashing: Given a string, check if it is isogram or not

Hashing: Given an array, find two non overlapping pairs having equal sum

Hashing: Given 2 strings, find uncommon characters

Hashing: Replace all the elements of the array by its rank in the array

Hashing: Given a sorted array, count the absolute distinct count

Hashing: Given 2 arrays, check if they are equal or not

Hashing: Given two arrays, sort first array according to the order of second array

Hashing: Find the first repeating element and index in the array

Hashing: Given an array, find the first missing positive number

Hashing: Given an array, find the majority element

Hashing: Given an array, find the element that occurs odd number of times

Hashing: Given 2 arrays, and a value x, you need to find the pairs sum equal to the given value of x.

Hashing: Given an array and a value k, return top k frequent elements

Hashing: Given an array, you need to find the missing number

Hashing: Given an array, count all the subsets with even numbers and are distinct

Hashing: Given an array, you need to count the frequency if the array elements

 

===============================
Dynamic Programming Questions
===============================

Dynamic Programming: Longest Palindromic Substring In C++ 

Dynamic Programming: Given an input string (s) and a pattern (p), implement regular expression matching with support for ‘.’ and ‘*’. 

Dynamic Programming: Rain water trapping

Dynamic Programming: Unique Paths Solution in CPP

Dynamic Programming: Unique Paths 2

Dynamic Programming: Minimum Path Sum in CPP

Dynamic Programming: Longest Increasing Subsequence

Dynamic Programming: Longest Bitonic Subsequence

Dynamic Programming: Get Max Coin In Game problem.

Dynamic Programming: Rod Cutting Problem

Dynamic Programming: Box Stacking Problem

Dynamic Programming: Building Bridges

Dynamic Programming: Egg Dropping Problem

Dynamic Programming: Min Edit Distance

Dynamic Programming: 0 1 Knapsack Problem using Dynamic Programming

Dynamic Programming: Binomial Coefficiet Problem

Dynamic Programming: Permutation Coefficient

Dynamic Programming: Get the nth catalan number

Dynamic Programming: Subset sum problem

Dynamic Programming: Unbounded Knapsack Problem

Dynamic Programming: Equal Sum partition

Dynamic Programming: Climb the stairs with minimum cost

Dynamic Programming: Robbing Houses

Dynamic Programming: Get the sum by deleting elements from the array

Dynamic Programming: Count of subset sum with a given sum

Dynamic Programming: Minimum subset difference

Dynamic Programming: Target Sum

Dynamic Programming: Count the number of subset with a given difference

Dynamic Programming: Minimum Number of swaps to make array increasing

Dynamic Programming: Longest Common Subsequence

Dynamic Programming: Print Longest Common Sub-sequence

Dynamic Programming: Length of Shortest Common Supersequence

Dynamic Programming: Print Shortest Common Supersequence

Dynamic Programming: Minimum number of deletions and insertions to convert one string into another

Dynamic Programming: Longest repeating subsequence

Dynamic Programming: Check if one string is a subsequence of another

Dynamic Programming: Count how many times string 1 appears as substring in string 2.

Dynamic Programming: Longest Common Substring

Dynamic Programming: Get the count of delete operations on 2 strings.

Dynamic Programming: Find the Maximum and minimum of an array

 

===============================
Divide and conquer Questions
===============================

Divide and Conquer: Implement pow(x, n), which calculates x raised to the power n (xn) in C++

 

===============================
Backtracking Questions
===============================

Backtracking: Given an array of non repeating numbers and a key, find all the unique combinations in that array, where the sum of those combination is equal to the key.

Backtracking: Letter Combinations of a Phone Number

Backtracking: The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.

Backtracking: Subsets II in CPP

Backtracking: Partition string into its palindrome

Backtracking: You are given an array with repeated elements and a key element, find all unique combination to the key

Backtracking: Get the k combination from an array of 1 to n

Backtracking: Find combination sum of k numbers that sum up to n

Backtracking: Letter case permutation

Backtracking: Get the sequential digits from the given range

Backtracking: Return the number of queens possible in a chessboard

Backtracking: Partition to K Equal Sum Subsets

Backtracking: Get maximum sum in a matrix

 

===============================
Binary Trees Questions
===============================

Binary Trees: Get difference between values at Even and Odd level in a binary tree

Binary Tree: Get Number of Nodes in a Binary Tree

Binary Tree: Display nodes at given level in Binary Tree

Binary Tree: Display Reverse Level Order Traversal by using queue

Binary Tree: Perform PreOrder traversal on a Binary Tree by without Recursion

Binary Tree: Perform InOrder traversal on a Binary Tree by without Recursion

Binary Tree: Perform PostOrder traversal on a Binary Tree by without Recursion

Binary Tree: Convert a binary tree to its Mirror Tree

Binary Tree: Check if Two Trees are Mirror Structure to each other

Binary Tree: Delete a binary tree

Binary Tree: Get Level of a Given Node

Binary Tree: Get Sum of elements Level wise in a Binary Tree

Binary Tree: Get Maximum width of Binary Tree

Binary Tree: Display elements between any two given level

Binary Tree: Check if binary tree is a height balanced tree?

Binary Tree: Check if all Leaf Nodes are at same level in Binary tree

Binary Tree: Find Parent of a given node value in Binary Tree

Binary Tree: Check if given Binary Tree is BST

Binary Tree: Find Sibling node of a given node value in Binary Tree

Binary Tree: Check if given two nodes are siblings to each other in Binary Tree

Binary Tree: Get Sum of all nodes formed from Root to Leaf Path

Binary Tree: Get Average of all nodes in Binary Tree

Binary Tree: Get Sum of all Leaf Nodes in Binary Tree

Binary Tree: Find Maximum or Minimum in Binary Tree

Binary Tree: Check if Binary Tree is Foldable Tree

Binary Tree: Check if two Binary Trees are Isomorphic

Binary Tree: Get Vertical Sum of Binary Tree

Binary Tree: Get deepest Left Leaf Node in Binary Tree

Binary Tree: Get depth of Odd level which contains Leaf node in Binary Tree

Binary Tree: Display all the leaf nodes from left to right and right to left in a tree

Binary Tree: Get count Non-Leaf nodes in a Binary Tree

Binary Tree: Get the count full nodes in a Binary

Binary Tree: Bottom view of binary Tree

Binary Tree: Boundary Traversal of Binary Tree

Binary Tree: Top view of a binary tree

Binary Tree: Left view and right view of a Binary Tree

Binary Tree: Level Order Traversal

Binary Tree: Vertical Order Traversal

Binary Tree: Height or Max depth if a BTree

Binary Tree: Spiral order or Zigzag traversal of a Binary Tree

Binary Tree: Diameter of a Binary Tree

Binary Tree: Lowest Common ancestor of a Binary Tree.

Binary Tree: Check if 2 nodes are mirror of each other

Binary Tree: Check if 2 binary tree are identical

Binary Tree: Check if binary tree is a sum tree

Binary Tree: Add all the node values in a Binary Tree or Sum of a Binary tree

Binary Tree: Print the number of leaf nodes in a binary tree

Binary Tree: Print all the paths from root node to leaf node

Binary Tree: Print the nodes at k distance from the root of a binary tree

Binary Trees: Diagonal Traversal of a Binary tree

Binary Trees: Convert Binary Tree to DLL

Binary Trees: Convert Binary tree into Sum tree

Binary Trees: Construct Binary Tree from preorder and inorder traversal

Binary Trees: Minimum swap required to convert binary tree to binary search tree

Binary Trees: Find Duplicate Subtrees

Binary Trees: Check if a given graph is tree or not

Binary Trees: Find largest subtree sum in a tree

Binary Trees: Maximum Sum of nodes in Binary tree such that no two are adjacent

Binary Trees: Kth Ancestor of a Tree Node

Binary Trees: Find Duplicate Subtrees

Binary Tree: Given a tree, delete leaf nodes with value k

Binary Tree: Given a binary tree, check if the tree is perfect or not.

Binary Tree: Maximum path sum in a binary tree

Binary Tree: Given a binary tree, perform reverse level order traversal

Binary Tree: Convert BST to Min Heap

Binary Tree: Given a BST and a target, find if a pair exists

Binary Tree: Convert BST to Max Heap

Binary Tree: Level order traversal of a Binary Tree

Binary Tree: Given a binary tree, connect nodes at the same level

Binary Tree: You are given a binary tree, you need to print the extreme nodes in alternate order.

Binary Tree: Given two trees, check if the structure are identical

Binary Tree: Given a binary tree and a value k, print all the nodes at distance k

Binary Tree: Given a binary tree, find the maximum path sum between two leaves

Binary Tree: Given a binary tree and a target, delete leaf nodes having value target

Binary Tree: Given a binary tree and a target, burn it

Binary Tree: Given a binary tree, check if the tree is a children sum property

Binary Tree: Given a binary tree, check if duplicate values are present

Binary Tree: Given a binary tree, check if there is duplicate subtree and return the duplicate subtree

Binary Tree: Given two trees, check if the tree is subtree of another tree

Binary Tree: Given a binary tree and two nodes, check if they are cousins

Binary Tree: Given a binary tree, invert it

 

===============================
Graph Questions
===============================

Graph: Detect a cycle in a directed graph

Graph: Detect a cycle in a undirected graph

Graph: Check if the given edge is a bridge in the graph

Graph: Check if undirected graph is connected or not

Graph: Count the number of connected components in an undirected graph

Graph: Reverse a directed graph

Graph: Given a directed graph, check if the incoming edges of a vertex is equal to the vertex itself.

Graph: Check if the undirected graph is a tree or not

Graph: Given an directed graph, find the in and out degree of all vertices

Graph: Find there is a path between 2 nodes in a directed graph

Graph: Get the maximum sum of values of nodes among all connected components of an undirected graph

Graph: Get the unique lengths of connected components of an undirected graph.

Graph: Find if there is a path between 2 nodes in an undirected graph

Graph: Check if a graph is a strongly connected using Kosaraju DFS algorithm

Graph: Dice Sum Problem

Graph: DFS graph traversal

Graph: Find the number of Islands

Graph: Check if the given courses can be completed with prerequisites

Graph: Given a graph, check if it is bipartite or not – Using BSF

Graph: Given a graph with source and destination, count all the possible path between two vertices

Graph: Given a matrix, find the distance of nearest cell having 0

Graph: Flood Fill algorithm

Graph: Find minimum time to rot all the oranges

Graph: Get all the paths from source to destination

Graph: Given a matrix, replace ‘o’ with ‘x’, if surrounded by ‘x’

Graph: You are given a graph, clone the graph using deep copy

Graph: Given a dictionary and a matrix, find all the words from the dictionary found in matrix

Graph: Given a binary matrix, find the largest region of 1

Graph: Given a matrix, find the number of closed islands

 

===============================
Binary Search Trees Questions
===============================

Binary Search Trees: Find a value in a BST

Binary Search Trees: Deletion of a node in a BST

Binary Search Trees: Find min and max value in a BST

Binary Search Trees: Find the Inorder predecessor and successor for a given key in BST

Binary Search Trees: A program to check if a binary tree is BST or not

Binary Search Trees: Convert a BST into greater sum tree

Binary Search Trees: LCA in a BST

Binary Search Trees: Construct BST from preorder traversal

Binary Search Trees: Convert Binary Tree into Binary Search Tree.

Binary Search Trees: Convert a normal BST into a Balanced BST

Binary Search Trees: Merge Two balanced BST

Binary Search Trees: Kth Largest Element in a BST

Binary Search Trees: Kth smallest Element in a BST

Binary Search Trees: Return the sum of given range in BST.

Binary Search Trees: Get the Shortest distance between two nodes in BST

Binary Search Trees: Count the number of BST nodes that lie in a given range.

Binary Search Trees: Convert sorted DLL to Balanced BST

Binary Search Trees: Find triplet sum in BST

Binary Search Trees: Check if the pre-order is a valid BST

Binary Search Trees: Check if the BST has a dead end

Binary Search Trees: Correct a BST where 2 nodes are swapped

Binary Search Trees: Flatten BST to sorted list

Binary Search Tree: Unique Binary Search Trees

Binary Search Trees: Given a sorted linked list into binary search tree

Binary Search Trees: Check If Preorder Traversal Is Valid BST

Binary Search Trees: Given an array, check if it represents inorder traversal of BST.

Binary Search Trees: Given a BST, check if each internal node has only one child

Binary Search Trees: Given 2 BST, check if it has same set of elements or not

Binary Search Trees: Given a BST and a key, find the next smaller element of that key

Binary Search Trees: Given a BST and a key, find the next greater element of that key

Binary Search Trees: Given a BST and a range, return the range sum of that BST

Binary Search Trees: Given two BST, print all elements

Binary Search Trees: Given a BST, find median in BST

Binary Search Trees: Given 2 BST, check if both contain same set of elements

Binary Search Trees: Given a BST, remove all the leaf nodes

Binary Search Trees: Given a BST and a key, search in a BST

Binary Search Trees: Given a sorted array, convert into balanced bst

Binary Search Trees: Given 2 BST, print common nodes in the BST

Binary Search Trees: Given a BST, find the second largest element in the BST

 

===============================
Greedy Questions
===============================

Greedy: Remove duplicates from a string

Greedy: Add elements in an array so the sum is equal to the given range

Greedy: Remove k digits from an number to make it a smallest integer.

Greedy: Get the minimum platforms needed to avoid delay in the train arrival.

Greedy: Check if the string is a substring of another string

Greedy: Remove overlapping intervals.

Greedy: Plant n flowers in flower bed

Greedy: Maximum meetings in one room

Greedy: Distribute Candy

Greedy: Schedule task efficiently

Greedy: Shuffle array so that one array element is greater than other array element

Greedy: Maximum sum of absolute difference of an array

Greedy: Partition characters

Greedy: Juice change

Greedy: Given a string, split into balanced strings.

Greedy: Perform operations on a broker calculator

Greedy: Add minimum to make parentheses valid.

Greedy: Remove covered intervals.

Greedy: Reduce the array size to the half

Greedy: String break problem

Greedy: Connect ropes with minimum cost.

Greedy: Find maximum sum possible equal sum of three stacks

Greedy: Maximum odd binary number

Greedy: Assign holes to mice

Greedy: Assign maximum cookies

Greedy: Given three stacks, you need to find maximum equal sum

Greedy: Non overlapping intervals

Greedy: Minimum swaps to make strings equal

Greedy: Insert new interval

Greedy: Reorganize String

Greedy: Replace the integer to 1 by following given conditions

Greedy: Check for Increasing triplet subsequence

Greedy: Given a string, partition the string such that each letter appears at only one part

Greedy: Given an array, find the longest alternative subsequence

Greedy: Check if a given string becomes palindrome by deleting atmost one char

Greedy: Get the maximum number by swapping once

Greedy: Given an array and a value k, check if we can have k consecutive numbers

Greedy: Given a number and a value k, return the smallest digit after removing k digits

Greedy: Given a string, return the length of longest palindrome

Greedy: Given a string, check if it is a valid parenthesis or not

 

===============================
2 pointers Questions
===============================

Two Pointers: Given an array, find 3 elements such that [a + b + c] = 0. Find all the 3 unique elements. 

Two Pointers: Given an array of n integers and an integer “key”, find three integers in the array such that the sum is closest to key. 

Two Pointers: Given an array n integers and an integer key, are there four elements a, b, c, and d in the array such that a + b + c + d = key? Find all unique quadruplets in the array which gives the sum of key. 

Two Pointers: Rain water trapping

Two Pointers: Reverse an array

Two Pointers: Arrays: Given an array find the duplicate number

Two Pointers: Arrays: Minimum swaps required to bring all elements less than or equal to k together

Two Pointers: Arrays: Get minimum number of merge operations to make an array palindrome

Two Pointers: Given an array and a value “m”, choose “m” elements having minimum difference between max and min

Two Pointers : Move all negative numbers to beginning and positive to end using extra space

Two Pointers: Count pairs with sum less than target

Two Pointers: Meeting rooms

Two Pointers: Given a string with special characters, reverse only alphabets

Two Pointers: Minimum boats to save people

Two Pointers: Given an array, sort the array by making element squares

Two Pointers: Given 2 arrays, find the common elements

Two Pointers: Given a binary array, return maximum consecutive ones

Two Pointers: Given a string, reverse the string by preserving whitespace.

Two Pointers: Given a binary string, check if the string has most number of contiguous segment of one

Two Pointers: Given an array and a value k, return the count of pairs with k difference

Two Pointers: Given two arrays find the intersection of two arrays

Two Pointers: Given two arrays with duplicate, you need to return the union of two arrays

Two Pointers: Given an array and a value K, you need to return the size of minimum subarray that is equal to k

Two Pointers: Given a array and a value k, return the number of subarray whose product is less that k

Two Pointers: Celebrity Problem

Two Pointers: Given an array, return the count of smallest subarray to be removed to make the remaining array sorted

 

===============================
Sliding Window Questions
===============================

Sliding Window: Strings: Smallest distinct window

Sliding Window: Strings: Minimum Window Substring

Sliding Window: Given a string, get the number of substrings having ‘a’, ‘b’, ‘c’

Sliding Window: Given an array and integer k, find the max sum of distinct subarray of length k

Sliding Window: Given an array and size k, find the first negative integer in each window of size k

Sliding Window: Given an array and a value k, find the maximum average subarray

Sliding Window: Return the maximum consecutive ones after flipping k zeros

Sliding Window: Return the number of sub array size k that is greater than or equal to threshold

Sliding Window: Given a string a variable k, count substring with k frequency characters

Sliding Window: Return he longest length of the substring with consecutive characters

Sliding Window: Maximum consecutive ones by flipping K bits

Sliding Window: Given an array, count maximum number of ones

Sliding Window: Subarrays with k odd numbers

Sliding Window: Longest substring without repeating character

Sliding Window: Longest substring after character replacement

Sliding Window: Return count of subarray with sum equal to k

Sliding Window: Given a string you need to find the longest non repeating substring

Sliding Window: Return length of longest subarray with having at most k frequency

Sliding Window: Fruits into baskets

Sliding Window: Maximum points you can obtain from cards

Sliding Window: Subarray with k different integers

Sliding Window: Smallest sum of contiguous subarray

Sliding Window: Given an array and a target value, get the subarray product less than k

 

===============================
Merge interval pattern
===============================

Merge interval pattern: Merge Overlapping Intervals

Merge interval pattern: Find intersection of all intervals

Merge interval pattern: Check if two intervals overlap

Merge interval pattern: Check if person can attend all the meetings

Merge interval pattern: Make Intervals Non Overlapping

 

===============================
Prefix sum problems
===============================

Prefix sum problems: Given an array find Equilibrium Index

Prefix sum problems: Bitwise OR of sum of all subsequence of the array

Prefix sum problems: Maximum equilibrium sum in an array

Prefix sum problems: Get original array from Prefix sum array

Prefix sum problems: Find the largest subarray with sum 0

Prefix sum problems: Longest subarray with sum k

Prefix sum problems: Given an array and value k, return the count of subarray with sum k

Prefix sum problems: Given bianry array and a value k, return the count of subarray sum

===============================
Kadane’s Algorithm
===============================

Kadane’s Algorithm: Maximum Subarray Sum

Kadane’s Algorithm: Maximum Circular Subarray Sum

Kadane’s Algorithm: Maximum Product Subarray

Kadane’s Algorithm: Maximum Subarray Sum after removing at most one element

Kadane’s Algorithm: Maximum Sum Rectangle In A 2D Matrix

Kadane’s Algorithm: Maximum Product Subarray

Kadane’s Algorithm: minimum size subarray sum

Kadane’s Algorithm: Largest sum increasing contiguous subarray

Kadane’s Algorithm: Maximum Product Subarray