Repository navigation
Expand file tree
/
Copy pathproblems.txt
More file actions
702 lines (590 loc) · 27.5 KB
/
Copy pathproblems.txt
File metadata and controls
702 lines (590 loc) · 27.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
Dynamic Programming:
1.Sum of all substrings of a number
2.Count numbers containing 4
3.Fibonaaccii numbers
4.Ugly numbers
5.Ways To Tile A Floor
6.Gold Mine Problem
7.Friends Pairing Problem
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
2.Longest Repeating Subsequence
3.LCS (Longest Common Subsequence) of three strings
4.perm_identity
Longest subsequence such that difference between adjacents is one
5.Maximum Length Chain of Pairs | DP-20
6.Maximum sum of pairs with specific difference
7.0 - 1 Knapsack Problem
Backtracking:
Standard Algorithms:
1.The Knight’s tour problem | Backtracking-1
2.Backtracking | Set 2 (Rat in a Maze)
3.Backtracking | Set 3 (N Queen Problem)
4.Hamiltonian Path
5.Backtracking | Set 7 (Sudoku)
6.Backtracking | Set 5 (m Coloring Problem)
7.Remove Invalid Parentheses
8.Rat in a Maze with multiple steps or jump allowed
Greedy Algorithms:
Standard Algorithms:
1.Activity Selection Problem
2.Job Sequencing Problem
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:
1.Minimum product subset of an array
2Maximum product subset of an array
3.Maximize array sum after K negations | Set 1
4.Maximize array sum after K negations | Set 2
5.Maximum sum of increasing order elements from n arrays
6.Maximize sum of consecutive differences in a circular array
7.Partition into two subarrays of lengths k and (N – k) such that the difference of sums is maximum
8.Minimum sum by choosing minimum of pairs from array
9.Minimum sum of absolute difference of pairs of two arrays
10.Minimum sum of two numbers formed from digits of an array
1.Minimum increment/decrement to make array non-Increasing
2.Making elements of two arrays same with minimum increment/decrement
3.Find if k bookings possible with given arrival and departure times
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
Strings:
Basics:
1.Pangram Checking
2.Rearrange characters in a string such that no two adjacent are same
3.Check Whether a number is Duck Number or not
4.Round the given number to nearest multiple of 10
Arthimetic Operation in String:
1.Minimum sum of squares of character counts in a given string after removing k characters
2.Maximum and minimum sums from two numbers with digit replacements
4.Sum of two large numbers
5.Calculate sum of all numbers present in a string
6.Extract maximum numeric value from a given string | Set 2 (Regex approach)
7.Calculate maximum value using ‘+’ or ‘*’ sign between two numbers in a string
8.Difference of two large numbers
9.Check if a large number is divisible by 4 or not
10.Check if a large number is divisible by 11 or not
1.Decimal representation of given binary string is divisible by 5 or not
2.Divide large number represented as string
3.To check divisibility of any large number by 999
4.Multiply Large Numbers represented as Strings
5.Calculate the difficulty of a sentence
6.Remainder with 7 for large numbers
7.Check whether a given number is even or odd
Character Counting Based Problems :
1.Count Uppercase, Lowercase, special character and numeric values
2.Find the smallest window in a string containing all characters of another string
3.Smallest window that contains all characters of string itself
4.Count number of substrings with exactly k distinct characters
6.Count words in a given string
7.Count substrings with same first and last characters
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
1.Print all distinct characters of a string in order (3 Methods)
2.Concatenated string with uncommon characters of two strings
3.Program to count vowels in a string (Iterative and Recursive)
4.Given a binary string, count number of substrings that start and end with 1.
5.Count words that appear exactly two times in an array of words
6.Check if frequency of all characters can become same by one removal
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
9.Remove characters from the first string which are present in the second string
10.Length of Longest sub-string that can be removed
String | Subsequence & Substring
1.Given two strings, find if first string is a subsequence of second
2.Number of subsequences of the form a^i b^j c^k
3.Count All Palindromic Subsequence in a given String
4.Find number of times a string occurs as a subsequence in given string
5.Count Distinct Subsequences
6.Count distinct occurrences as a subsequence
7.Longest common subsequence with permutations allowed
8.Minimum number of palindromic subsequences to be removed to empty a binary string
9.Longest Repeating Subsequence
10.Find largest word in dictionary by deleting some characters of given string
1.Print all Subsequences of String which Start with Vowel and End with Consonant.
2.Find if a given string can be represented from a substring by iterating the substring “n” times
3.Longest common substring in binary representation of two numbers
4.Find the longest substring with k unique characters in a given string
5.Maximum length substring having all same characters after k changes
6.Find length of longest subsequence of one string which is substring of another string
7.Longest repeating and non-overlapping substring
8.Length of the longest valid substring
9.Length Of Last Word in a String
10.Longest Even Length Substring such that Sum of First and Second Half is same
1.Sum of all substrings of a string representing a number |Set2 (Constant Extra Space)
2.Number of even substrings in a string of digits
3.Length of the smallest sub-string consisting of maximum distinct characters
Spacing :
1.Remove spaces from a given string
2.Put spaces between words starting with capital letters
3.URLify a given string (Replace spaces is %20)
4.String containing first letter of every word in a given string with spaces
5.Print all possible strings that can be made by placing spaces
Case Sensitive String :
1.Lower case to upper case – An interesting fact
2.Print all words matching a pattern in CamelCase Notation Dictonary
3.How to design a tiny URL or URL shortener?
Anagram :
1.Check whether two strings are anagram of each other
2.Given a sequence of words, print all anagrams together | Set 1
3.Anagram Substring Search (Or Search for all permutations)
4.Remove minimum number of characters so that two strings become anagram
5.Check if two strings are k-anagrams or not
6.Check if two strings are permutation of each other
7.Check if any anagram of a string is palindrome or not
8.Minimum Number of Manipulations required to make two Strings Anagram Without Deletion of Character
Reverse & Rotation :
1.Length of the smallest sub-string consisting of maximum distinct characters
2.Check if a string can be obtained by rotating another string 2 places
3.Write a program to reverse an array or string
4.Reverse an array without affecting special characters
5.Reverse words in a given string b
6.Reverse a string preserving space positions
7.Reverse vowels in a given string
8.Perfect reversible string
Occurrence Based String :
1.Given a string, find its first non-repeating character
2.Find the first non-repeating character from a stream of characters
3.Convert to a string that is repetition of a substring of k length
4.Queue based approach for first non-repeating character in a stream
5.Find the first repeated word in a string
6.Find the first repeated character in a string
7.Second most repeated word in a sequence
8.Most frequent word in an array of strings
9.Efficiently find first repeated character in a string without using any additional data structure in one traversal
10.Return maximum occurring character in an input string
11.Print the string by ignoring alternate occurrences of any character
2.Print the string after the specified character has occurred given no. of times
Palindrome:
1.C Program to Check if a Given String is Palindrome
2.Check if a given string is a rotation of a palindrome
3.Minimum insertions to form a palindrome | DP-28
4.Longest Palindromic Substring | Set 2
5.Count All Palindrome Sub-Strings in a String | Set 1
6.Count All Palindromic Subsequence in a given String
8.Minimum steps to delete a string after repeated deletion of palindrome substrings
9.Longest Palindromic Subsequence | DP-12
10.Minimum insertions to form a palindrome with permutations allowed
11.Count of Palindromic substrings in an Index range
12.Find all distinct palindromic sub-strings of a given string
Sorting & Searching :
1.Alternate Lower Upper String Sort
2.Rearrange a string in sorted order followed by the integer sum
Linked List:
1.Linked List | Set 2 (Inserting a node)
2.Linked List | Set 3 (Deleting a node)
3.Delete a Linked List node at a given position
4.Find Length of a Linked List (Iterative and Recursive)
5.Write a function to get Nth node in a Linked List
6.Program for n’th node from the end of a Linked List
7.Find the middle of a given linked list
8.Write a function that counts the number of times a given int occurs in a Linked List
9.Detect loop in a linked list
10.Find length of Loop
1.Function to check if a singly linked list is palindrome
2.Remove duplicates from an unsorted linked list
3.Remove duplicates from a sorted linked list
4.Pairwise swap elements of a given linked list
5.Intersection of two Sorted Linked Lists
6.QuickSort on Singly Linked List
7.Segregate even and odd nodes in a Linked List
8.Reverse a linked list
9.Print reverse of a Linked List without actually reversing
10.Merge two sorted linked lists such that merged list is in reverse order
1.Reverse a Linked List in groups of given size
2.Delete alternate nodes of a Linked List
3.Alternating split of a given Singly Linked List 4.Identical Linked Lists
5.Delete nodes which have a greater value on right side
6.Add two numbers represented by linked lists
7.Rotate a Linked List
8.Flattening a Linked List
9.Sort a linked list of 0s, 1s and 2s
10.Delete N nodes after M nodes of a linked list
1.Clone a linked list with next and random pointer
2.Sort linked list which is already sorted on absolute values
3.Check if a linked list of strings forms a palindrome
4.Pairwise swap elements of a given linked list by changing links
5.Rearrange a given linked list in-place.
6.Sort a linked list that is sorted alternating ascending and descending orders?
7.Compare two strings represented as linked lists
8.Rearrange a linked list such that all even and odd positioned nodes are together
9.Rearrange a Linked List in Zig-Zag fashion
10.Add 1 to a number represented as linked list
1.Merge Sort for Linked Lists
2.Merge two sorted linked lists
3.Merge a linked list into another linked list at alternate positions
4.Delete middle of linked list
5.Merge K sorted linked lists | Set 1
6.Merge k sorted linked lists | Set 2 (Using Min Heap)
7.Merge two sorted lists (in-place)
8.Union and Intersection of two Linked Lists
9.Union and Intersection of two linked lists | Set-2 (Using Merge Sort)
10.Union and Intersection of two linked lists | Set-3 (Hashing)
1.Insert node into the middle of the linked list
2.Sort a linked list of 0s, 1s and 2s by changing links
3.An interesting method to print reverse of a linked list
4.Given only a pointer/reference to a node to be deleted in a singly linked list, how do you delete it?
5.Why Quick Sort preferred for Arrays and Merge Sort for Linked Lists?
6.Find the fractional (or n/k – th) node in linked list
7.Find modular node in a linked list
8.Construct a linked list from 2D matrix
9.Arrange consonants and vowels nodes in a linked list
10.Modify contents of Linked List
11.Remove loop in a linked list
Doubly Linked List:
1.Doubly Linked List Introduction and Insertion
2.Delete a node in a Doubly Linked List
3.Reverse a Doubly Linked List
4.QuickSort on Doubly Linked List
5.Swap Kth node from beginning with Kth node from end in a Linked List
6.Merge Sort for Doubly Linked List
7.Convert a given Binary Tree to Doubly Linked List | Set 4
8.Extract Leaves of a Binary Tree in a Doubly Linked List
Arrays:
Rotation:
1.Print left rotation of array in O(n) time and O(1) space
2.Find the minimum element in a sorted and rotated array
3.Find the Rotation Count in Rotated Sorted array
4.Maximum sum of i*arr[i] among all rotations of a given array
5.Search an element in a sorted and rotated array
6.Program to cyclically rotate an array by one
7.Count rotation divisible by 4
8.Check if a string can be obtained by rotating another string 2 place
9.Inplace rotate square matrix by 90 degrees
Array Rearrangement:
1.Distinct adjacent elements in an array
2.Rearrange positive and negative numbers in O(n) time and O(1) extra space
3.Minimum swaps required to bring all elements less than or equal to k together
4.Rearrange array such that even positioned are greater than odd
5.Rearrange an array in order – smallest, largest, 2nd smallest, 2nd largest, .
6.Double the first element and move zero to end
7.Arrange given numbers to form the biggest number | Set 1
8.Move all negative elements to end in order with extra space allowed
9.Replace every array element by multiplication of previous and next
10.Maximum Product Subarray
11.Form minimum number from given sequence
12.Convert array into Zig-Zag fashion
13.Three way partitioning of an array around a given range
14.Sort an array according to the order defined by another array
15.Sort an array of 0s, 1s and 2s
Array | Order Statistics
1.Kth smallest element in a row-wise and column-wise sorted 2D array
2.Find all elements in array which have at-least two greater elements
3.Minimum product of k integers in an array of positive Integers
4.Maximum sum such that no two elements are adjacent
5.Maximum and minimum of an array using minimum number of comparisons
6.Maximum difference between two elements such that larger element appears after the smaller number
7.Count smaller elements on right side
8.Given an array arr[], find the maximum j – i such that arr[j] > arr[i]
9.Sliding Window Maximum (Maximum of all subarrays of size k)
10.Find the minimum distance between two numbers
1.Count Strictly Increasing Subarrays
2.Find zeroes to be flipped so that number of consecutive 1’s is maximized
3.Smallest greater elements in whole array
4.Find the closest pair from two sorted arrays
5.Maximum Sum Path in Two Arrays
6.Given an array of of size n and a number k, find all elements that appear more than n/k times
7.Longest Increasing Subsequence Size (N log N)
8.Find the smallest positive number missing from an unsorted array
Arrays Optimization Problems:
1.Largest Sum Contiguous Subarray
2.Find the subarray with least average
3.Find the minimum distance between two numbers
4Minimum number of jumps to reach end
5.Dynamic Programming | Set 14 (Maximum Sum Increasing Subsequence)
6.Smallest subarray with sum greater than a given value
7.Find maximum average subarray of k length
8.Count minimum steps to get the given desired array
9.Find minimum number of merge operations to make an array palindrome
10.Find the smallest positive integer value that cannot be represented as sum of any subset of a given array
11.Find minimum difference between any two elements
12.Longest Span with same Sum in two Binary arrays
Array Sorting:
1.Alternative Sorting
2.Sort a nearly sorted (or K sorted) array
3.Sort an array according to absolute difference with given value
4.Sort an array in wave form
5.Sort elements by frequency
6.Count Inversions in an array | Set 1 (Using Merge Sort)
7.Two elements whose sum is closest to zero
8.Minimum number of swaps required to sort an array
9.Union and Intersection of two sorted arrays
10.Find Union and Intersection of two unsorted arrays
11.Find the Minimum length Unsorted Subarray, sorting which makes the complete array sorted
12.Count the number of possible triangles
13.Elements to be added so that all elements of a range are present in array
14.Count all distinct pairs with difference equal to k
15.Merge two sorted arrays with O(1) extra space
16.Program to check if an array is sorted or not (Iterative and Recursive)
17.Maximize the sum of arr[i]*i
18.Pairs with Difference less than K
19.Merging two unsorted arrays in sorted order
20.Sort an array after applying the given equation
21.Sum of minimum absolute difference of each array element
Array Matrix:
1.Search in a row wise and column wise sorted matrix
2.Print a given matrix in spiral form
3.A Boolean Matrix Question
4.Print unique rows in a given boolean matrix
5.Maximum size square sub-matrix with all 1s
6.Zigzag (or diagonal) traversal of Matrix
7.Flood fill Algorithm
8.Sorted matrix
9.Given a matrix of ‘O’ and ‘X’, replace ‘O’ with ‘X’ if surrounded by ‘X’
10.Find the longest path in a matrix with given constraints
1.Find the largest rectangle of 1’s with swapping of columns allowed
2.Validity of a given Tic-Tac-Toe board configuration
3.Minimum Initial Points to Reach Destination
4.Rotate Matrix Elements
5.Number of paths with exactly k coins
6.Maximum size rectangle binary sub-matrix with all 1s
7.Shortest path in a Binary Maze
8.Inplace rotate square matrix by 90 degrees
9.Dynamic Programming | Set 27 (Maximum sum rectangle in a 2D matrix)
Array Searching:
1.Find common elements in three sorted arrays
2.Maximum Subarray Sum Excluding Certain Elements
3.Equilibrium index of an array
4.Majority Element
5.Check for Majority Element in a sorted array
6.Find the two repeating elements in a given array
7.Find a Fixed Point (Value equal to index) in a given array
8.Find subarray with given sum | Set 1 (Nonnegative Numbers)
9.Smallest Difference Triplet from Three arrays
10.Count triplets with sum smaller than a given value
11.Find a triplet such that sum of two equals to third element
12.Find the Number Occurring Odd Number of Times
13.Find lost element from a duplicated array
14.Find the repeating and the missing | Added 3 new methods
15.Find the two numbers with odd occurrences in an unsorted array
16.Find four elements that sum to a given value | Set 1 (n^3 solution)
17.Find four elements that sum to a given value | Set 2 ( O(n^2Logn) Solution)
18.Check if a given array contains duplicate elements within k distance from each other
19.Trapping Rain Water
20.Consecutive steps to roof top
21.Print n smallest elements from given array in their original order
22.Find first k natural numbers missing in given array
23.Find sum of non-repeating (distinct) elements in an array
24.Check whether Arithmetic Progression can be formed from the given array
25.Count ways of choosing a pair with maximum difference
26.Maximum sum of pairwise product in an array with negative allowed
bit algorithms:
1.Smallest power of 2 greater than or equal to n
2.Add 1 to a given number
3.How to swap two numbers without using a temporary variable
4.Check if binary representation of a number is palindrome
5.Efficient way to multiply with 7
6.Euclid’s Algorithm when % and / operations are costly
7.Find the element that appears once
8.Interesting Facts about Bitwise Operators in C
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
12.C++ bitset interesting facts
13.Builtin functions of GCC compiler
14.Bits manipulation (Important tactics)
15.Bit Tricks for Competitive Programming
Queue:
1.Queue
2.Applications of Queue Data Structure
3.Priority Queue
4.Applications of Priority Queue
5.Deque
6.Circular Queue
1.Implement Queue using Stacks
2.LRU Cache Implementation
3.Implement Stack using Queues
4.Queue | Set 2 (Linked List Implementation)
5.Implement a stack using single queue
6.Implementation of Deque using circular array
7.Circular Queue | Set 2 (Circular Linked List Implementation)
1.Breadth First Traversal or BFS for a Graph
2.Level Order Tree Traversal
3.Reverse a path in BST using queue
4.Construct Complete Binary Tree from its Linked List Representation
5.Program for Page Replacement Algorithms | Set 2 (FIFO)
6.Check whether a given Binary Tree is Complete or not | Set 1 (Iterative Solution)
7.ZigZag Tree Traversal
1.Reversing a Queue
2.Reversing a queue using recursion
3.Reversing the first K elements of a Queue
4.Interleave the first half of the queue with second half
1.Level order traversal in spiral form
2.Sliding Window Maximum (Maximum of all subarrays of size k)
3.Find the first circular tour that visits all petrol pumps
4.Smallest multiple of a given number made of digits 0 and 9 only
5.First non-repeating character in a stream
6.An Interesting Method to Generate Binary Numbers from 1 to n
7.Minimum time required to rot all oranges
8.Find maximum level sum in Binary Tree
9.Sum of minimum and maximum elements of all subarrays of size k.
10.First negative integer in every window of size k
STACK:
1.Implement Queue using Stacks
2.Implement two stacks in an array
3.Implement Stack using Queues
4.Create a customized data structure which evaluates functions in O(1)
5.Design a stack that supports getMin() in O(1) time and O(1) extra space
6.Implement a stack using single queue
1.Infix to Postfix Conversion using Stack
2.Check for balanced parentheses in an expression
3.Next Greater Element
4.Next Greater Frequency Element
5.Number of NGEs to the right
6.Print next greater number of Q queries
7.Design a stack with operations on middle element
8.The Celebrity Problem
9.The Stock Span Problem
10.Iterative Tower of Hanoi
1.Sort a stack using recursiongeSort for arrays.
2.Sort a stack using a temporary stack
3.Largest Rectangular Area in a Histogram | Set 2
4.Find maximum of minimum for every window size in a given array
5.Length of the longest valid substring
6.Check if a given array can represent Preorder Traversal of Binary Search Tree
7.Find maximum difference between nearest left and right smaller elements
heap:
1.Binary Heap
2K’th Smallest/Largest Element in Unsorted Array | Set 1
3.Check if a given Binary Tree is Heap
4.Convert BST to Min Heap
5.Merge k sorted arrays | Set 1
6.Binomial Heap
7.Sum of all elements between k1’th and k2’th smallest elements
8.Convert min Heap to max Heap
9.Heap Sort
10.Print all nodes less than a value x in a Min Heap.
1.K’th largest element in a stream
2.Minimum sum of two numbers formed from digits of an array
3.Rearrange characters in a string such that no two adjacent are same
4.Maximum difference between two subsets of m elements
5.Time Complexity of building a heap
6.Iterative Heap Sort
7.Maximum distinct elements after removing k elements
8.Largest triplet product in a stream
9.Minimum product of k integers in an array of positive Integers
10.Median in a stream of integers (running integers)
sorting:
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:
1.Write a program to Delete a Tree
2.Diameter of a Binary Tree
3.Given a binary tree, print out all of its root-to-leaf paths one per line
4.Populate Inorder Successor for all nodes
5.Check if a given Binary Tree is SumTree
6.Print Ancestors of a given node in Binary Tree
7.Print nodes at k distance from root
8.Maximum width of a binary tree
9.Find next right node of a given key
10.Tree Isomorphism Problem
1.Connect nodes at same level
2.Check if a binary tree is subtree of another binary tree
3.Print Nodes in Top View of Binary Tree
4.Vertical Sum in a given Binary Tree | Set 1
5.Deepest left leaf node in a binary tree
6.Print Left View of a Binary Tree
7.Check if all leaves are at same level
8.Find the maximum path sum between two leaves of a binary tree
9.Print Right View of a Binary Tree
10.Print Nodes in Bottom View of Binary Tree
1.Deletion in a Binary Tree
2.Find the closest leaf in a Binary Tree
3.Check if two nodes are cousins in a Binary Tree
4.Print all nodes that don’t have sibling
5.Diagonal sum of binary tree
6.Lowest Common Ancestor in a Binary Tree
7.Min distance between two given nodes of a Binary Tree
8.Convert a Binary Tree into its Mirror Tree
9.Binary Tree (Properties)
10.Print a Binary Tree in Vertical Order
1.Maximum difference between node and its ancestor
2.K-th ancestor of a node in Binary Tree
3.Longest consecutive sequence in Binary tree
4.Duplicate subtree in Binary Tree
5.Print all k-sum paths in a binary tree
6.Print Nodes having K leaves
7.Number of root to leaf paths
8.Largest BST
Binary search tree:
1.Binary Search Tree | Set 1 (Search and Insertion
2.Binary Search Tree | Set 2 (Delete)
3.Binary Tree to Binary Search Tree Conversion
4.A program to check if a binary tree is BST or not
5.Find k-th smallest element in BST
6.K’th Largest Element in BST when modification to BST is not allowed
7.Check whether BST contains Dead End or not
8.Inorder Successor in Binary Search Tree
9.Two nodes of a BST are swapped, correct the BST
10.Inorder predecessor and successor for a given key in BST
1.Sum of k smallest elements in BST
2.Find the closest element in Binary Search Tree
3.Replace every element with the least greater element on its right
4.Print Common Nodes in Two Binary Search Trees
5.Count BST nodes that lie in a given range
6.Given n appointments, find all conflicting appointments
7.Find median of BST in O(n) time and O(1) space
8.Binary Tree to DLL
9.Floor and Ceil from a BST
10.Lowest Common Ancestor in a BST
Hashing:
1.Find whether an array is subset of another array
2.Given an array A[] and a number x, check for pair in A[] with sum as x
3.Minimum delete operations to make all elements of array same
4.Number of subarrays having sum exactly equal to k
5.k-th distinct (or non-repeating) element in an array.
6.Frequency of each element in an unsorted array
7.Find k numbers with most occurrences in the given array
8.Print All Distinct Elements of a given integer array
9.Pairs of Positive Negative values in an array
10.Sort elements by frequency
1.Find the largest subarray with 0 sum
2.Longest subarray with sum divisible by k
3.Longest subsequence such that difference between adjacents is one
4.Find four elements a, b, c and d in an array such that a+b = c+d
5.Maximum difference between first and last indexes of an element in array
6.Check if array contains contiguous integers with duplicates allowed
7.Count distinct elements in every window of size k
8.Subset with no pair sum divisible by K
9.Find subarray with given sum
10.Count subsets having distinct even numbers
1.Largest subarray with equal number of 0s and 1s
2.Range Queries for Frequencies of array elements
3.Find all triplets with zero sum
4.Count of index pairs with equal elements in an array
5.Minimum number of distinct elements after removing m items
6.Subarrays with distinct elements
7.Elements to be added so that all elements of a range are present in array
8.Find smallest range containing elements from k lists
9.Count subarrays having total distinct elements same as original array
10.Hash Table vs STL Map
11.Advantages of BST over Hash Table