pmutua / coding

Why do we fall?

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem Topics cover:

1.Arrays

2.Bit Algorithms

3.String

4.Queue

5.Stack

6.Singly Linked List

7.Doubly Linked List

8.Sorting

9.Binary Tree

10.Binary Search Tree

11.Heap

12.Hashing

13.DP

14.Backtracking

15.Greedy

16.Misc

Arrays:

Rotation:

1.Print left rotation of array in O(n) time and O(1) space See Solution

2.Find the minimum element in a sorted and rotated array See Solution

3.Find the Rotation Count in Rotated Sorted array See Solution

4.Maximum sum of i*arr[i] among all rotations of a given array See Solution

5.Search an element in a sorted and rotated array See Solution

6.Program to cyclically rotate an array by one See Solution

7.Count rotation divisible by 4 See Solution
Permutations of a string See Solution
Permutations of a string (Without Duplicates) See Solution
Divisibility By Four See Solution

8.Check if a string can be obtained by rotating another string 2 place See Solution
Rotations of String See Solution

9.Inplace rotate square matrix by 90 degrees See Solution

Array Rearrangement:

1.Distinct adjacent elements in an array See Solution

2.Rearrange positive and negative numbers in O(n) time and O(1) extra space See Solution

3.Minimum swaps required to bring all elements less than or equal to k together See Solution

4.Rearrange array such that even positioned are greater than odd See Solution

5.Rearrange an array in order – smallest, largest, 2nd smallest, 2nd largest, . See Solution

6.Double the first element and move zero to end See Solution
Move Zeroes to End See Solution

7.Arrange given numbers to form the biggest number | Set 1 See Solution

8.Move all negative elements to end in order with extra space allowed See Solution

9.Replace every array element by multiplication of previous and next See Solution

Subarray and SubSequence See Solution

10.Maximum Product Subarray See Solution

11.Form minimum number from given sequence See Solution

12.Convert array into Zig-Zag fashion See Solution

13.Three way partitioning of an array around a given range See Solution
Quick Sort See Solution

14.Sort an array according to the order defined by another array See Solution

15.Sort an array of 0s, 1s and 2s See Solution
Sort Binary Array 0s and 1s See Solution
Array | Order Statistics

1.Kth smallest element in a row-wise and column-wise sorted 2D array See Solution

2.Find all elements in array which have at-least two greater elements See Solution

3.Minimum product of k integers in an array of positive Integers See Solution

4.Maximum sum such that no two elements are adjacent See Solution

5.Maximum and minimum of an array using minimum number of comparisons See Solution

6.Maximum difference between two elements such that larger element appears after the smaller number See Solution

7.Count smaller elements on right side See Solution

8.Given an array arr[], find the maximum j – i such that arr[j] > arr[i] See Solution

9.Sliding Window Maximum (Maximum of all subarrays of size k) See Solution

10.Find the minimum distance between two numbers See Solution

1.Count Strictly Increasing Subarrays See Solution

2.Find zeroes to be flipped so that number of consecutive's is maximized See Solution

3.Smallest greater elements in whole array See Solution

4.Find the closest pair from two sorted arrays See Solution
Closest Pair in a sorted array See Solution

5.Maximum Sum Path in Two Arrays See Solution
6.Given an array of of size n and a number k, find all elements that appear more than n/k times See Solution

7.Longest Increasing Subsequence Size (N log N) (N^2) See Solution

8.Find the smallest positive number missing from an unsorted array See Solution

Arrays Optimization Problems:

1.Largest Sum Contiguous Subarray See Solution
2.Find the subarray with least average See Solution

3.Find the minimum distance between two numbers Seen Already

4.Minimum number of jumps to reach end See Solution

5.Dynamic Programming | Set 14 (Maximum Sum Increasing Subsequence) See Solution

6.Smallest subarray with sum greater than a given value See Solution

7.Find maximum average subarray of k length See Solution

8.Count minimum steps to get the given desired array See Solution

9.Find minimum number of merge operations to make an array palindrome See Solution

10.Find the smallest positive integer value that cannot be represented as sum of any subset of a given array See Solution

11.Find minimum difference between any two elements See Solution

12.Longest Span with same Sum in two Binary arrays See Solution

Array Sorting:

1.Alternative Sorting See Solution

2.Sort a nearly sorted (or K sorted) array See Solution

3.Sort an array according to absolute difference with given value See Solution

4.Sort an array in wave form See Solution

5.Sort elements by frequency See Solution

6.Count Inversions in an array | Set 1 (Using Merge Sort) See Solution

7.Two elements whose sum is closest to zero See Solution

8.Minimum number of swaps required to sort an array See Solution

Merge Sort O(nlogn) time with O(n) space See Solution

9.Union and Intersection of two sorted arrays See Solution

10.Find Union and Intersection of two unsorted arrays See Solution

11.Find the Minimum length Unsorted Subarray, sorting which makes the complete array sorted See Solution

12.Count the number of possible triangles See Solution

13.Elements to be added so that all elements of a range are present in array See Solution

14.Count all distinct pairs with difference equal to k See Solution

15.Merge two sorted arrays with O(1) extra space See Solution

16.Program to check if an array is sorted or not (Iterative and Recursive) See Solution

17.Maximize the sum of product of arr[i] and i See Solution

18.Pairs with Difference less than K See Solution

19.Merging two unsorted arrays in sorted order See Solution

20.Sort an array after applying the given equation See Solution

21.Sum of minimum absolute difference of each array element See Solution

Array Matrix:

1.Search in a row wise and column wise sorted matrix See Solution

2.Print a given matrix in spiral form See Solution

3.A Boolean Matrix Question See Solution

4.Print unique rows in a given boolean matrix See Solution

5.Maximum size square sub-matrix with all 1s See Solution

6.Zigzag (or diagonal) traversal of Matrix See Solution

7.Flood fill Algorithm See Solution

8.Sorted matrix See Solution

9.Given a matrix of 'O' and 'X', replace 'O' with 'X' if surrounded by 'X' See Solution

10.Find the longest path in a matrix with given constraints See Solution

1.Find the largest rectangle of 1's with swapping of columns allowed See Solution

2.Validity of a given Tic-Tac-Toe board configuration See Solution

3.Minimum Initial Points to Reach Destination See Solution

4.Rotate Matrix Elements

5.Number of paths with exactly k coins

6.Maximum size rectangle binary sub-matrix with all 1s See Solution
Largest Area of a histogram - Linear Solution See Solution

7.Shortest path in a Binary Maze See Solution
8.Inplace rotate square matrix by 90 degrees See Solution

9.Dynamic Programming | Set 27 (Maximum sum rectangle in a 2D matrix)

Array Searching:

1.Find common elements in three sorted arrays See Solution

2.Maximum Subarray Sum Excluding Certain Elements See Solution

3.Equilibrium index of an array See Solution

4.Majority Element See Solution

5.Check for Majority Element in a sorted array See Solution

6.Find the two repeating elements in a given array See Solution

7.Find a Fixed Point (Value equal to index) in a given array See Solution

8.Find subarray with given sum | Set 1 (Nonnegative Numbers)

9.Smallest Difference Triplet from Three arrays See Solution

10.Count triplets with sum smaller than a given value See Solution

11.Find a triplet such that sum of two equals to third element See Solution

12.Find the Number Occurring Odd Number of Times See Solution

13.Find lost element from a duplicated array See Solution

14.Find the repeating and the missing | Added 3 new methods See Solution

15.Find the two numbers with odd occurrences in an unsorted array See Solution

16.Find four elements that sum to a given value | Set 1 (n^3 solution) See Solution

17.Find four elements that sum to a given value | Set 2 ( O(n^2) Solution) See Solution

18.Check if a given array contains duplicate elements within k distance from each other See Solution

19.Trapping Rain Water See Solution

20.Consecutive steps to roof top See Solution
21.Print n smallest elements from given array in their original order See Solution

22.Find first k natural numbers missing in given array See Solution

23.Find sum of non-repeating (distinct) elements in an array See Solution

24.Check whether Arithmetic Progression can be formed from the given array See Solution

25.Count ways of choosing a pair with maximum difference See Solution

26.Maximum sum of pairwise product in an array with negative allowed See Solution

Bit algorithms:

Bit Manipulations Basics See Solution

1.Smallest power of 2 greater than or equal to n See Solution

2.Add 1 to a given number See Solution

3.How to swap two numbers without using a temporary variable See Solution

4.Check if binary representation of a number is palindrome See Solution

5.Efficient way to multiply with 7 See Solution

6.Euclid's Algorithm when % and / operations are costly See Solution

7.Find the element that appears once See Solution

8.Interesting Facts about Bitwise Operators in C See Solution

9.Optimization Techniques | Set 1 (Modulus)

10.What are the differences between bitwise and logical AND operators in C/C++?

11.Bit Fields in C Read

12.C++ bitset interesting facts Read

13.Builtin functions of GCC compiler Read

14.Bits manipulation (Important tactics)

15.Bit Tricks for Competitive Programming Read

Strings:

Basics:

1.Pangram Checking See Solution

2.Rearrange characters in a string such that no two adjacent are same See Solution

3.Check Whether a number is Duck Number or not See Solution

4.Round the given number to nearest multiple of 10 See Solution

Arthimetic Operation in String:

1.Minimum sum of squares of character counts in a given string after removing k characters See Solution

2.Maximum and minimum sums from two numbers with digit replacements See Solution

4.Sum of two large numbers See Solution

5.Calculate sum of all numbers present in a string See Solution

6.Extract maximum numeric value from a given string See Solution

7.Calculate maximum value using '+' or '*' sign between two numbers in a string See Solution

8.Difference of two large numbers See Solution

9.Check if a large number is divisible by 4 or not See Solution

10.Check if a large number is divisible by 11 or not See Solution

1.Decimal representation of given binary string is divisible by 5 or not See Solution

2.Divide large number represented as string See Solution

3.To check divisibility of any large number by 999 See Solution

4.Multiply Large Numbers represented as Strings See Solution

5.Calculate the difficulty of a sentence See Solution

6.Remainder with 7 for large numbers See Solution

7.Check whether a given number is even or odd See Solution

Character Counting Based Problems :

1.Count Uppercase, Lowercase, special character and numeric values See Solution

2.Find the smallest window in a string containing all characters of another string See Solution

3.Smallest window that contains all characters of string itself See Solution

4.Count number of substrings with exactly k distinct characters See Solution

6.Count words in a given string See Solution

7.Count substrings with same first and last characters See Solution

8.Count number of strings (made of R, G and B) using given combination

9.Count of strings that can be formed using a, b and c under given constraints

10.Count number of equal pairs in a string See Solution

1.Print all distinct characters of a string in order (3 Methods) See Solution

2.Concatenated string with uncommon characters of two strings See Solution

3.Program to count vowels in a string (Iterative and Recursive) See Solution

4.Given a binary string, count number of substrings that start and end with 1. See Solution

5.Count words that appear exactly two times in an array of words See Solution

6.Check if frequency of all characters can become same by one removal See Solution

7.Count ways to increase LCS length of two strings by one

8.Find the character in first string that is present at minimum index in second string See Solution

9.Remove characters from the first string which are present in the second string See Solution

10.Length of Longest sub-string that can be removed See Solution

String | Subsequence & Substring

1.Given two strings, find if first string is a subsequence of second See Solution

2.Number of subsequences of the form a^i b^j c^k See Solution

3.Count All Palindromic Subsequence in a given String See Solution

4.Find number of times a string occurs as a subsequence in given string See Solution

5.Count Distinct Subsequences

6.Count distinct occurrences as a subsequence See Solution

7.Longest common subsequence with permutations allowed See Solution

8.Minimum number of palindromic subsequences to be removed to empty a binary string See Solution

9.Longest Repeating Subsequence See Solution
Longest Common Subsequence See Solution

10.Find largest word in dictionary by deleting some characters of given string See Solution

1.Print all Subsequences of String which Start with Vowel and End with Consonant. See Solution

2.Find if a given string can be represented from a substring by iterating the substring "n" times See Solution

3.Longest common substring in binary representation of two numbers

4.Find the longest substring with k unique characters in a given string See Solution

5.Maximum length substring having all same characters after k changes See Solution

6.Find length of longest subsequence of one string which is substring of another string See Solution

Longest Common Substring See Solution
7.Longest repeating and non-overlapping substring See Solution

8.Length of the longest valid substring See Solution

9.Length Of Last Word in a String See Solution

10.Longest Even Length Substring such that Sum of First and Second Half is same See Solution

1.Sum of all substrings of a string representing a number |Set2 (Constant Extra Space) See Solution

2.Number of even substrings in a string of digits See Solution

3.Length of the smallest sub-string consisting of maximum distinct characters See Solution

Spacing :

1.Remove spaces from a given string See Solution

2.Put spaces between words starting with capital letters See Solution

3.URLify a given string (Replace spaces is %20) See Solution

4.String containing first letter of every word in a given string with spaces See Solution

5.Print all possible strings that can be made by placing spaces See Solution

Case Sensitive String :

1.Lower case to upper case – An interesting fact See Solution

2.Print all words matching a pattern in CamelCase Notation Dictonary See Solution

3.How to design a tiny URL or URL shortener? See Solution

Anagram :

1.Check whether two strings are anagram of each other See Solution

2.Given a sequence of words, print all anagrams together | Set 1 See Solution

3.Anagram Substring Search (Or Search for all permutations) See Solution

4.Remove minimum number of characters so that two strings become anagram See Solution

5.Check if two strings are k-anagrams or not See Solution

6.Check if two strings are permutation of each other See Solution

7.Check if any anagram of a string is palindrome or not See Solution

8.Minimum Number of Manipulations required to make two Strings Anagram Without Deletion of Character See Solution

Reverse & Rotation :

1.Length of the smallest sub-string consisting of maximum distinct characters See Solution

2.Check if a string can be obtained by rotating another string 2 placesSee Solution

3.Write a program to reverse an array or string See Solution

4.Reverse an array without affecting special characters See Solution

5.Reverse words in a given string b See Solution

6.Reverse a string preserving space positions See Solution

7.Reverse vowels in a given string See Solution

8.Perfect reversible string See Solution

Occurrence Based String :

1.Given a string, find its first non-repeating character See Solution

2.Find the first non-repeating character from a stream of characters See Solution

3.Convert to a string that is repetition of a substring of k length See Solution

4.Queue based approach for first non-repeating character in a stream See Solution

5.Find the first repeated word in a string See Solution

6.Find the first repeated character in a string See Solution

7.Second most repeated word in a sequence See Solution

8.Most frequent word in an array of strings See Solution

9.Efficiently find first repeated character in a string without using any additional data structure in one traversal See Solution

10.Return maximum occurring character in an input string See Solution

11.Print the string by ignoring alternate occurrences of any character See Solution

12.Print the string after the specified character has occurred given no. of times See Solution

Palindrome:

1.C Program to Check if a Given String is Palindrome See Solution

2.Check if a given string is a rotation of a palindrome See Solution

3.Minimum insertions to form a palindrome | DP-28 See Solution

4.Longest Palindromic Substring | Set 2 See Solution

5.Count All Palindrome Sub-Strings in a String | Set 1 See Solution

Count of Unique Palindromic Substrings See Solution

6.Count All Palindromic Subsequence in a given String See Solution

8.Minimum steps to delete a string after repeated deletion of palindrome substrings

9.Longest Palindromic Subsequence | DP-12 See Solution

10.Minimum insertions to form a palindrome with permutations allowed See Solution

11.Count of Palindromic substrings in an Index range

12.Find all distinct palindromic sub-strings of a given string See Solution

Sorting & Searching :

1.Alternate Lower Upper String Sort See Solution

2.Rearrange a string in sorted order followed by the integer sum See Solution

Queue:

1.Queue See Solution

2.Applications of Queue Data Structure See Solution

3.Priority Queue See Solution

4.Applications of Priority Queue See Solution

5.Deque See Solution

6.Circular Queue See Solution

1.Implement Queue using Stacks See Solution

2.LRU Cache Implementation See Solution

3.Implement Stack using Queues See Solution

4.Queue | Set 2 (Linked List Implementation) See Solution

5.Implement a stack using single queue See Solution

6.Implementation of Deque using circular array

7.Circular Queue | Set 2 (Circular Linked List Implementation) See Solution

1.Breadth First Traversal or BFS for a Graph See Solution

2.Level Order Tree Traversal See Solution

3.Reverse a path in BST using queue

4.Construct Complete Binary Tree from its Linked List Representation See Solution

5.Program for Page Replacement Algorithms | Set 2 (FIFO) See Solution

6.Check whether a given Binary Tree is Complete or not | Set 1 (Iterative Solution) See Solution

7.ZigZag Tree Traversal See Solution

1.Reversing a Queue See Solution

2.Reversing a queue using recursion See Solution

3.Reversing the first K elements of a Queue See Solution

4.Interleave the first half of the queue with second half See Solution

1.Level order traversal in spiral form See Solution

2.Sliding Window Maximum (Maximum of all subarrays of size k) See Solution

3.Find the first circular tour that visits all petrol pumps See Solution

4.Smallest multiple of a given number made of digits 0 and 9 only See Solution

5.First non-repeating character in a stream See Solution

6.An Interesting Method to Generate Binary Numbers from 1 to n See Solution

7.Minimum time required to rot all oranges See Solution

8.Find maximum level sum in Binary Tree See Solution

9.Sum of minimum and maximum elements of all subarrays of size k. See Solution

10.First negative integer in every window of size k

STACK:

1.Implement Queue using Stacks See Solution
Single Stack

2.Implement two stacks in an array See Solution

3.Implement Stack using Queues See Solution

4.Create a customized data structure which evaluates functions in O(1) See Solution

5.Design a stack that supports getMin() in O(1) time and O(1) extra space See Solution

6.Implement a stack using single queue See Solution

1.Infix to Postfix Conversion using Stack See Solution

2.Check for balanced parentheses in an expression See Solution

3.Next Greater Element See Solution

4.Next Greater Frequency Element See Solution

5.Number of NGEs to the right See Solution

6.Print next greater number of Q queries See Solution

7.Design a stack with operations on middle element See Solution

8.The Celebrity Problem See Solution

9.The Stock Span Problem See Solution

10.Iterative Tower of Hanoi See Solution

1.Sort a stack using recursiongeSort for arrays. See Solution

2.Sort a stack using a temporary stack See Solution

3.Largest Rectangular Area in a Histogram | Set 2 See Solution

4.Find maximum of minimum for every window size in a given array

5.Length of the longest valid substring See Solution

6.Check if a given array can represent Preorder Traversal of Binary Search Tree See Solution

7.Find maximum difference between nearest left and right smaller elements

Linked List:

1.Linked List | Set 2 (Inserting a node) See Solution

2.Linked List | Set 3 (Deleting a node) See Solution

3.Delete a Linked List node at a given position See Solution

4.Find Length of a Linked List (Iterative and Recursive) See Solution

5.Write a function to get Nth node in a Linked List See Solution

6.Program for n'th node from the end of a Linked List See Solution

7.Find the middle of a given linked list See Solution

8.Write a function that counts the number of times a given int occurs in a Linked List See Solution

9.Detect loop in a linked list See Solution

10.Find length of Loop See Solution

1.Function to check if a singly linked list is palindrome See Solution

2.Remove duplicates from an unsorted linked list See Solution

3.Remove duplicates from a sorted linked list See Solution

4.Pairwise swap elements of a given linked list See Solution

5.Intersection of two Sorted Linked Lists See Solution

6.QuickSort on Singly Linked List

7.Segregate even and odd nodes in a Linked List See Solution

8.Reverse a linked list See Solution

9.Print reverse of a Linked List without actually reversing See Solution

10.Merge two sorted linked lists such that merged list is in reverse order See Solution

1.Reverse a Linked List in groups of given size See Solution

2.Delete alternate nodes of a Linked List See Solution

3.Alternating split of a given Singly Linked List See Solution

4.Identical Linked Lists See Solution

5.Delete nodes which have a greater value on right side See Solution

6.Add two numbers represented by linked lists See Solution

7.Rotate a Linked List See Solution

8.Flattening a Linked List See Solution

9.Sort a linked list of 0s, 1s and 2s See Solution

10.Delete N nodes after M nodes of a linked list See Solution

1.Clone a linked list with next and random pointer See Solution

2.Sort linked list which is already sorted on absolute values See Solution

3.Check if a linked list of strings forms a palindrome See Solution

4.Pairwise swap elements of a given linked list by changing links See Solution

5.Rearrange a given linked list in-place. See Solution

6.Sort a linked list that is sorted alternating ascending and descending orders? See Solution

7.Compare two strings represented as linked lists See Solution

8.Rearrange a linked list such that all even and odd positioned nodes are together See Solution

9.Rearrange a Linked List in Zig-Zag fashion See Solution

10.Add 1 to a number represented as linked list See Solution

1.Merge Sort for Linked Lists See Solution

2.Merge two sorted linked lists See Solution

3.Merge a linked list into another linked list at alternate positions See Solution

4.Delete middle of linked list See Solution

5.Merge K sorted linked lists | Set 1 See Solution

6.Merge k sorted linked lists | Set 2 (Using Min Heap) See Solution

7.Merge two sorted lists (in-place) See Solution

8.Union and Intersection of two Linked Lists See Solution

9.Union and Intersection of two linked lists | Set-2 (Using Merge Sort) See Solution

10.Union and Intersection of two linked lists | Set-3 (Hashing) See Solution

1.Insert node into the middle of the linked list See Solution

2.Sort a linked list of 0s, 1s and 2s by changing links See Solution

3.An interesting method to print reverse of a linked list See Solution

4.Given only a pointer/reference to a node to be deleted in a singly linked list, how do you delete it? See Solution

5.Why Quick Sort preferred for Arrays and Merge Sort for Linked Lists? See Solution

6.Find the fractional (or n/k – th) node in linked list See Solution

7.Find modular node in a linked list See Solution

8.Construct a linked list from 2D matrix See Solution

9.Arrange consonants and vowels nodes in a linked list See Solution

10.Modify contents of Linked List See Solution

11.Remove loop in a linked list See Solution

Doubly Linked List:

1.Doubly Linked List Introduction and Insertion See Solution

2.Delete a node in a Doubly Linked List See Solution

3.Reverse a Doubly Linked List See Solution

4.QuickSort on Doubly Linked List

5.Swap Kth node from beginning with Kth node from end in a Linked List See Solution

6.Merge Sort for Doubly Linked List See Solution

7.Convert a given Binary Tree to Doubly Linked List | Set 4 See Solution

8.Extract Leaves of a Binary Tree in a Doubly Linked List See Solution

Sorting:

See All Solutions here

1.Selection Sort

2.Bubble Sort

3.Recursive Bubble Sort

4.Insertion Sort

5.Recursive Insertion Sort

6.Merge Sort

7.Iterative Merge Sort

8.Quick Sort

9.Iterative Quick Sort

10.Heap Sort

11.Counting Sort

12.Radix sort

BINARY TREE:

General Intro Read

1.Write a program to Delete a Tree See Solution

2.Diameter of a Binary Tree See Solution

3.Given a binary tree, print out all of its root-to-leaf paths one per line See Solution

4.Populate Inorder Successor for all nodes See Solution

5.Check if a given Binary Tree is SumTree See Solution

6.Print Ancestors of a given node in Binary Tree See Solution

7.Print nodes at k distance from root See Solution

8.Maximum width of a binary tree See Solution

9.Find next right node of a given key See Solution

10.Tree Isomorphism Problem See Solution

1.Connect nodes at same level See Solution

2.Check if a binary tree is subtree of another binary tree See Solution

3.Print Nodes in Top View of Binary Tree See Solution

4.Vertical Sum in a given Binary Tree | Set 1 See Solution

5.Deepest left leaf node in a binary tree See Solution

6.Print Left View of a Binary Tree See Solution

7.Check if all leaves are at same level See Solution

8.Find the maximum path sum between two leaves of a binary tree See Solution

9.Print Right View of a Binary Tree See Solution

10.Print Nodes in Bottom View of Binary Tree See Solution

1.Deletion in a Binary Tree See Solution

2.Find the closest leaf in a Binary Tree See Solution

3.Check if two nodes are cousins in a Binary Tree See Solution

4.Print all nodes that don't have sibling See Solution

Diagonal Traversal of binary tree See Solution
5.Diagonal sum of binary tree See Solution

6.Lowest Common Ancestor in a Binary Tree See Solution

7.Min distance between two given nodes of a Binary Tree See Solution

8.Convert a Binary Tree into its Mirror Tree See Solution

9.Binary Tree (Properties) See Solution

10.Print a Binary Tree in Vertical Order See Solution

1.Maximum difference between node and its ancestor See Solution

2.K-th ancestor of a node in Binary Tree See Solution

3.Longest consecutive sequence in Binary tree See Solution

Serialize and Deserialize Binary Tree See Solution

4.Duplicate subtree in Binary Tree See Solution

Path Sum with given Value See Solution
Path Sum paths With Given Value See Solution
5.Print all k-sum paths in a binary tree See Solution

6.Print Nodes having K leaves See Solution

7.Number of root to leaf paths See Solution

8.Largest BST See Solution

Binary search tree:

1.Binary Search Tree | Set 1 (Search and Insertion) See Solution

2.Binary Search Tree | Set 2 (Delete) See Solution

3.Binary Tree to Binary Search Tree Conversion See Solution

4.A program to check if a binary tree is BST or not See Solution

5.Find k-th smallest element in BST See Solution

6.K'th Largest Element in BST when modification to BST is not allowed See Solution

7.Check whether BST contains Dead End or not See Solution

8.Inorder Successor in Binary Search Tree See Solution

9.Two nodes of a BST are swapped, correct the BST See Solution

10.Inorder predecessor and successor for a given key in BST See Solution

1.Sum of k smallest elements in BST See Solution

2.Find the closest element in Binary Search Tree See Solution

Iterative Inorder Traversal See Solution

3.Replace every element with the least greater element on its right See Solution

4.Print Common Nodes in Two Binary Search Trees See Solution

5.Count BST nodes that lie in a given range See Solution

6.Given n appointments, find all conflicting appointments See Solution

7.Find median of BST in O(n) time and O(1) space See Solution

8.Binary Tree to DLL See Solution

9.Floor and Ceil from a BST See Solution

10.Lowest Common Ancestor in a BST See Solution

Tree Traversals See Solution

Heap:

1.Binary Heap See Solution

2K'th Smallest/Largest Element in Unsorted Array | Set 1 See Solution

3.Check if a given Binary Tree is Heap See Solution

4.Convert BST to Min Heap See Solution

5.Merge k sorted arrays | Set 1 See Solution

6.Binomial Heap

7.Sum of all elements between k1'th and k2'th smallest elements See Solution

8.Convert min Heap to max Heap See Solution

9.Heap Sort See Solution

10.Print all nodes less than a value x in a Min Heap. See Solution

1.K'th largest element in a stream See Solution

2.Minimum sum of two numbers formed from digits of an array See Solution

3.Rearrange characters in a string such that no two adjacent are same See Solution

4.Maximum difference between two subsets of m elements See Solution

5.Time Complexity of building a heap

6.Iterative Heap Sort

7.Maximum distinct elements after removing k elements See Solution

8.Largest triplet product in a stream See Solution

9.Minimum product of k integers in an array of positive Integers See Solution

10.Median in a stream of integers (running integers) See Solution

Hashing:

1.Find whether an array is subset of another array See Solution

2.Given an array A[] and a number x, check for pair in A[] with sum as x See Solution

3.Minimum delete operations to make all elements of array same See Solution

4.Number of subarrays having sum exactly equal to k See Solution

5.k-th distinct (or non-repeating) element in an array. See Solution

6.Frequency of each element in an unsorted array See Solution

7.Find k numbers with most occurrences in the given array See Solution

8.Print All Distinct Elements of a given integer array See Solution

9.Pairs of Positive Negative values in an array See Solution

10.Sort elements by frequency See Solution

1.Find the largest subarray with 0 sum See Solution

2.Longest subarray with sum divisible by k See Solution

3.Longest subsequence such that difference between adjacents is one See Solution

4.Find four elements a, b, c and d in an array such that a+b = c+d See Solution

5.Maximum difference between first and last indexes of an element in array See Solution

Check if array elements are consecutive See Solution

6.Check if array contains contiguous integers with duplicates allowed See Solution

7.Count distinct elements in every window of size k See Solution

8.Subset with no pair sum divisible by K

9.Find subarray with given sum See Solution

10.Count subsets having distinct even numbers See Solution

1.Largest subarray with equal number of 0s and 1s See Solution

2.Range Queries for Frequencies of array elements See Solution

3.Find all triplets with zero sum See Solution

4.Count of index pairs with equal elements in an array See Solution

5.Minimum number of distinct elements after removing m items See Solution

6.Subarrays with distinct elements See Solution

7.Elements to be added so that all elements of a range are present in array See Solution

8.Find smallest range containing elements from k lists See Solution

9.Count subarrays having total distinct elements same as original array See Solution

10.Hash Table vs STL Map See Solution

11.Advantages of BST over Hash Table See Solution

Dynamic Programming:

Coin Change Min Coins See Solution Largest SubSquare Matrix See Solution
0/1 Knapsack Problem See Solution
1.Sum of all substrings of a number See Solution
Partition Equal Sum Subset See Solution
Shortest Common SuperSequence See Solution
Longest Increasing Subsequence See Solution
Edit Distance See Solution
Matrix Chain Multiplication See Solution
Rod Cutting See Solution
Word Break See Solution
2.Count numbers containing 4

3.Fibonaaccii numbers See Solution

4.Ugly numbers

5.Ways To Tile A Floor

6.Gold Mine Problem See Solution

7.Friends Pairing Problem See Solution

8.Perfect Sum Problem

9.Find maximum length Snake sequence

10.perm_identity

Sequences of given length where every element is more than or equal to twice of previous

1.Longest Common Subsequence | DP-4 See Solution

2.Longest Repeating Subsequence See Solution

3.LCS (Longest Common Subsequence) of three strings See Solution

4.perm_identity

Longest subsequence such that difference between adjacents is one See Solution

5.Maximum Length Chain of Pairs | DP-20 See Solution

6.Maximum sum of pairs with specific difference See Solution

7. 0 - 1 Knapsack Problem See Solution

Count ways to top using stairs See Solution

Longest Path Matrix See Solution

Subset Sum See Solution
Backtracking:

Print Binary and Decimal Numbers See Solution Dice Rolls See Solution
Permute StringSee Solution
Power Lists See Solution
Subsets and Subsets With Duplicates See Solution
Combination Sum See Solution Palindrome Partitioning See Solution
Generate matched paranthesis See Solution
Standard Algorithms:

1.The Knight's tour problem | Backtracking-1 See Solution

2.Backtracking | Set 2 (Rat in a Maze) See Solution

3.Backtracking | Set 3 (N Queen Problem) See Solution

4.Hamiltonian Path See Solution

5.Backtracking | Set 7 (Sudoku) See Solution

6.Backtracking | Set 5 (m Coloring Problem) See Solution

7.Remove Invalid Parentheses

8.Rat in a Maze with multiple steps or jump allowed See Solution

Greedy Algorithms:

Standard Algorithms:

1.Activity Selection Problem See Solution

2.Job Sequencing Problem See Solution

3.Huffman Coding | Greedy Algo-3

4.Huffman Decoding

5.Water Connection Problem

6.Policemen catch thieves

7.Minimum Swaps for Bracket Balancing

8.Fitting Shelves Problem

9.Assign Mice to Holes

Arrays Greedy problems:

Max product of three numbers See Solution

1.Minimum product subset of an array See Solution

2.Maximum product subset of an array See Solution

3.Maximize array sum after K negations | Set 1 See Solution

4.Maximize array sum after K negations | Set 2 See Solution

5.Maximum sum of increasing order elements from n arrays See Solution

6.Maximize sum of consecutive differences in a circular array See Solution

7.Partition into two subarrays of lengths k and (N – k) such that the difference of sums is maximum See Solution

8.Minimum sum by choosing minimum of pairs from array See Solution

9.Minimum sum of absolute difference of pairs of two arrays See Solution

10.Minimum sum of two numbers formed from digits of an array See Solution

1.Minimum increment/decrement to make array non-Increasing

2.Making elements of two arrays same with minimum increment/decrement See Solution

3.Find if k bookings possible with given arrival and departure times See Solution

4.Lexicographically smallest array after at-most K consecutive swaps

5.Largest lexicographic array with at-most K consecutive swaps

Misc:

1.Split n into maximum composite numbers

2.Maximum trains for which stoppage can be provided

3.Buy Maximum Stocks if i stocks can be bought on i-th day

4.Find the minimum and maximum amount to buy all N candies

5.Find maximum sum possible equal sum of three stacks

6.Maximum elements that can be made equal with k updates

7.Divide cuboid into cubes such that sum of volumes is maximum

8.Maximum number of customers that can be satisfied with given quantity

9.Minimum Fibonacci terms with sum equal to K

10.Divide 1 to n into two groups with minimum sum difference

TODO Problems: See here

About

Why do we fall?