DDSA
POTD Solutions

GeeksforGeeks Java Solutions

Daily Problem of the Day solutions — clean Java code for every GFG POTD.

531
Solved
Advertisement

531 problems

#Title
10 - 1 Knapsack Problem
22D Difference Array
32D Submatrix Sum Queries
4Activity Selection
5Add 1 to a Linked List Number
6Add Binary Strings
7Add Number Linked Lists
8Aggressive Cows
9Alien Dictionary
10All numbers with specific difference
11All Subsets Xor Sum
12All Unique Permutations of an array
13Allocate Minimum Pages
14Alternate positive and negative numbers
15Alternative Sorting
16Anagram
17Ancestors in Binary Tree
18AND In Range
19Array Duplicates
20Array to BST
21Articulation Point - II
22ASCII Range Sum
23Assign Mice Holes
24Balancing Consonants and Vowels Ratio
25Bellman-Ford
26BFS of graph
27Binary Tree to DLL
28Bitonic Point
29Boolean Parenthesization
30Bottom View of Binary Tree
31Brackets in Matrix Chain Multiplication
32Bridge edge in a graph
33BST to greater sum tree
34BST with Dead End
35Burning Tree
36Bus Conductor
37Bus Ticket Change
38Candy
39Case-specific Sorting of Strings
40Check for BST
41Check if a String is Subsequence of Other
42Check if frequencies can be equal
43Check If two Line segments Intersect
44Chocolate Distribution Problem
45Chocolate Pickup II
46Circle of strings
47Clone a linked list with next and random pointer
48Clone an Undirected Graph
49Clone List with Next and Random
50Closest Neighbour in BST
51Closest Three Sum
52Coin Change (Count Ways)
53Coin Change (Minimum Coins)
54Coin Piles
55Compare two fractions
56Construct an array from its pair-sum array
57Construct Binary Tree from Parent Array
58Construct Tree from Inorder & Preorder
59Construct Tree from Preorder & Postorder
60Container With Most Water
61Count all triplets with given sum in sorted array
62Count distinct elements in every window
63Count elements less than or equal to k in a sorted rotated array
64Count Indices to Balance Even and Odd Sums
65Count Inversions
66Count Linked List Nodes
67Count Numbers Containing Specific Digits
68Count of distinct substrings
69Count pairs Sum in matrices
70Count Pairs whose sum is less than target
71Count pairs with given sum
72Count Reverse Pairs
73Count set bits
74Count Smaller elements
75Count Subarray with k odds
76Count Subarrays with given XOR
77Count Subset With Target Sum II
78Count the Coprimes
79Count the number of possible triangles
80Count the paths
81Count Unique Vowel Strings
82Count ways to N'th Stair(Order does not matter)
83Count X in Range of a Sorted Array
84Counting elements in two arrays
85Course Schedule II
86Coverage of all Zeros in a Binary Matrix
87Cutting Binary String
88Decode the string
89Delete Alternate Nodes
90Delete node in Doubly Linked List
91Deletion and Reverse in Circular Linked List
92Design MinMax Queue
93Detect Loop in linked list
94DFS of Graph
95Diameter of a Binary Tree
96Dice throw
97Difference Check
98Dijkstra Algorithm
99Directed Graph Cycle
100Distance of nearest cell having 1
101Distribute Candies
102Divisible by 13
103Duplicate Subtrees
104Edit Distance
105Elements in range [a, b]
106Equalize the Towers
107Equilibrium Point
108Evaluation of Postfix Expression
109Exactly one swap
110Expression Add Operators
111Expression contains redundant bracket or not
112Extract the Number from the String
113Facing the sun
114Farthest Smaller Right
115Find all possible palindromic partitions of a String
116Find All Triplets with Zero Sum
117Find H-Index
118Find K Smallest Sum Pairs
119Find Kth Rotation
120Find length of Loop
121Find maximum volume of a cuboid
122Find median in a stream
123Find Only Repetitive Element from 1 to n-1
124Find rectangle with corners as 1
125Find the closest pair from two arrays
126Find the first node of loop in linked list
127Find the longest string
128Find the number of islands
129Find the Sum of Last N nodes of the Linked List
130Fixing Two nodes of a BST
131Flattening a Linked List
132Flood fill Algorithm
133Floyd Warshall
134Form a palindrome
135Form the Largest Number
136Frog Jump
137Game of XOR
138Game with String
139Gas Station
140Generate all binary strings
141Generate Binary Numbers
142Generate IP Addresses
143Generate Permutations of an array
144Get Min from Stack
145Get Minimum Squares
146Gold Mine Problem
147Graph Diameter
148Group Balls by Sequence
149Happiest Triplet
150Height of Binary Tree
151Histogram Max Rectangular Area
152Identical Linked Lists
153Implement Atoi
154Implement k Queues in a Single Array
155Implement Pow
156Implement Trie
157Indexes of Subarray Sum
158Inorder Traversal
159Insert in Sorted Circular Linked List
160Insert in Sorted way in a Sorted DLL
161Insert Interval
162Integral Points Inside Triangle
163Interleave the First Half of the Queue with Second Half
164Interleaved Strings
165Intersection in Y Shaped Lists
166Intersection of Two arrays with Duplicate Elements
167Intersection Point in Y Shaped Linked Lists
168Is Binary Tree Heap
169Is Linked List Length Even
170Job Sequencing Problem
171Josephus problem
172K closest elements
173K Closest Points to Origin
174K closest Values
175k largest elements
176K Sized Subarray Maximum
177K Sum Paths
178K-Pangrams
179K-th element of two Arrays
180K-th Largest Sum Contiguous Subarray
181k-th Smallest in BST
182Kadane's Algorithm
183Koko Eating Bananas
184Kth distance
185Kth element in Matrix
186Kth Missing Positive Number in a Sorted Array
187Kth Smallest
188Kth Smallest Number in Multiplication Table
189Largest BST
190Largest Divisible Subset
191Largest number in K swaps
192Largest number in one swap
193Largest Pair Sum
194Largest square formed in a matrix
195Largest subarray of 0's and 1's
196Last Moment Before All Ants Fall Out
197LCM Triplet
198LCS of three strings
199Left Rotate Matrix K times
200Left View of Binary Tree
201Length of Longest Cycle in a Graph
202Level Order in spiral form
203Level order traversal
204Lexicographically Largest String After Deleting K Characters
205Linked List Group Reverse
206Linked List Matrix
207Linked list of strings forms a palindrome
208Longest alternating subsequence
209Longest Bounded-Difference Subarray
210Longest Common Increasing Subsequence
211Longest Common Prefix of Strings
212Longest Common Subsequence
213Longest Common Substring
214Longest Consecutive Subsequence
215Longest Increasing Subsequence
216Longest Palindrome in a String
217Longest Palindromic Subsequence
218Longest Periodic Proper Prefix
219Longest Prefix Suffix
220Longest Span in two Binary Arrays
221Longest String Chain
222Longest Subarray Length
223Longest subarray with Atmost two distinct integers
224Longest Subarray with Majority Greater than K
225Longest Subarray with Sum K
226Longest substring with distinct characters
227Longest Substring with K Uniques
228Longest valid Parentheses
229Look and Say Pattern
230Lowest Common Ancestor in a BST
231LRU Cache
232Majority Element
233Majority Element II
234Majority Vote
235Make array elements unique
236Make Binary Tree From Linked List
237Make Matrix Beautiful
238Make Strings Equal
239Matrix Chain Multiplication
240Max Circular Subarray Sum
241Max DAG Edges
242Max distance between same elements
243Max min Height
244Max of min for every window size
245Max rectangle
246Max Score from Subarray Mins
247Max sum in the configuration
248Max Sum Increasing Subsequence
249Max sum path in two arrays
250Max Sum Subarray of size K
251Max Xor Subarray of size K
252Maximise String Score
253Maximize Array Value After Rearrangement
254Maximize median after doing k addition operation
255Maximize Number of 1's
256Maximize partitions in a String
257Maximize The Cut Segments
258Maximize the minimum difference between k elements
259Maximum Connected group
260Maximum Difference
261Maximum Non-Adjacent Nodes Sum
262Maximum Non-Overlapping Odd Palindrome Sum
263Maximum number of overlapping Intervals
264Maximum of minimum for every window size
265Maximum path sum
266Maximum path sum from any node
267Maximum People Visible in a Line
268Maximum Product Subarray
269Maximum product subset of an array
270Maximum Stone Removal
271Maximum subarray sum 2
272Maximum Sum Combination
273Maximum sum of elements not part of LIS
274Maximum sum of Non-adjacent nodes
275Maximum sum Rectangle
276Maximum XOR of two numbers in an array
277Median in a row-wise sorted Matrix
278Median of BST
279Median of two sorted arrays
280Meeting Rooms
281Meeting Rooms III
282Merge K sorted linked lists
283Merge Sort for Linked List
284Merge two BST 's
285Merge two sorted linked lists
286Merge Without Extra Space
287Middle of a Linked List
288Min Add to Make Parentheses Valid
289Min Chars to Add for Palindrome
290Min Cost Climbing Stairs
291Minimal Cost
292Minimize the Heights I
293Minimize the Heights II
294Minimum Cost of ropes
295Minimum Cost Path
296Minimum cost to connect all houses in a city
297Minimum Cost to cut a board into squares
298Minimum Cost to Cut a Stick of length N
299Minimum Cost to Merge Stones
300Minimum days to make M bouquets
301Minimum Deletions
302Minimum Jumps
303Minimum K Consecutive Bit Flips
304Minimum number of deletions and insertions
305Minimum Number of Workers
306Minimum Operations to Connect Hospitals
307Minimum Platforms
308Minimum repeat to make substring
309Minimum Steps to Halve Sum
310Minimum sum
311Minimum Weight Cycle
312Minimum Window Subsequence
313Mirror Tree
314Missing And Repeating
315Missing Element in Range
316Missing element of AP
317Missing in Array
318Mobile numeric keypad
319Modify the Array
320Move All Zeroes to End
321Multiply two linked lists
322Multiply two strings
323N meetings in one room
324N-Queen Problem
325nCr
326Nearest multiple of 10
327Nearly sorted
328Next element with greater frequency
329Next Greater Element
330Next Greater Element in Circular Array
331Next Permutation
332Nine Divisors
333Non Repeating Character
334Non-overlapping Intervals
335Not a subset sum
336Nth Natural Number
337Number of BST From Array
338Number of distinct subsequences
339Number of occurrence
340Number of pairs
341Number of paths in a matrix with k coins
342Number of Rectangles in a Circle
343Number of Ways to Arrive at Destination
344Occurence of an integer in a Linked List
345Optimal binary search tree
346Optimal Strategy For A Game
347Overlapping Intervals
348Pair Sum in BST
349Pair with given sum in a sorted array
350Pairs with difference k
351Palindrome Linked List
352Palindrome Sentence
353Palindrome SubStrings
354Parenthesis Checker
355Partition Equal Subset Sum
356Pascal Triangle
357Path With Minimum Effort
358Peak element
359Permutations of a String
360Police and Thieves
361Populate Inorder Successor for all nodes
362Possible Words From Phone Digits
363Postfix Evaluation
364Postorder Traversal
365Power of k in factorial of n
366Powerful Integer
367Predecessor and Successor
368Prime List
369Prime Pair with Target Sum
370Print Anagrams Together
371Print Bracket Number
372Print leaf nodes from preorder traversal of BST
373Product array puzzle
374Pythagorean Triplet
375Queue Reversal
376Quick Sort on Linked List
377Rat in a Maze
378Rat in a Maze Problem - I
379Remaining String
380Remove all occurences of duplicates in a linked list
381Remove BST keys outside given range
382Remove Duplicates
383Remove duplicates in array
384Remove Half Nodes
385Remove loop in Linked List
386Remove the balls
387Reorganize The Array
388Replace O's with X's
389Reverse a Doubly Linked List
390Reverse a linked list
391Reverse an Array
392Reverse Words
393Roman Number to Integer
394Roof Top
395Root to leaf path sum
396Root to Leaf Paths
397Root to leaf paths sum
398Rotate a Linked List
399Rotate and delete
400Rotate Array
401Rotate by 90 degree
402Rotate Deque By K
403Rotten Oranges
404Row with max 1s
405Safe States
406Search in a Row-Column sorted matrix
407Search in a row-wise sorted matrix
408Search in a sorted Matrix
409Search in an almost Sorted Array
410Search in fully rotated sorted 2D matrix
411Search in Rotated Sorted Array
412Search insert position of K in a sorted array
413Search Pattern (KMP-Algorithm)
414Search Pattern (Rabin-Karp Algorithm)
415Second Best Minimum Spanning Tree
416Second Largest
417Segregate 0s and 1s
418Serialize and deserialize a binary tree
419Set Matrix Zeroes
420Set Matrix Zeros
421Shop in Candy Store
422Shortest Common Supersequence
423Shortest Cycle
424Shortest path in Undirected Graph
425Shortest Path in Weighted undirected graph
426Shortest Path Using Atmost One Curved Edge
427Single Number
428Smallest distinct window
429Smallest Divisor
430Smallest number
431Smallest Positive Missing
432Smallest Positive Missing Number
433Smallest range in K lists
434Smallest window containing all characters
435Smallest window in a string containing all the characters of another string
436Solve the Sudoku
437Sort 0s, 1s and 2s
438Sort a k sorted doubly linked list
439Sort a linked list of 0s, 1s and 2s
440Sort by Absolute Difference
441Sort in specific order
442Sort the given array after applying the given equation
443Sorted and Rotated Minimum
444Sorted subsequence of size 3
445Sorting Elements of an Array by Frequency
446Spirally traversing a matrix
447Split an array into two equal Sum subarrays
448Split array in three equal sum subarrays
449Split Array Largest Sum
450Split Array Subsequences
451Split Linked List Alternatingly
452Split the Array
453Square root of a number
454Stickler Thief
455Stickler Thief II
456Stock Buy and Sell – Max 2 Transactions Allowed
457Stock Buy and Sell – Max K Transactions Allowed
458Stock Buy and Sell – Max one Transaction Allowed
459Stock Buy and Sell – Multiple Transaction Allowed
460Stock Buy and Sell with Cooldown
461Stock span problem
462Stream First Non-repeating
463String stack
464Strings Rotations of Each Other
465Sub-arrays with equal number of occurences
466Subarray range with given sum
467Subarrays With At Most K Distinct Integers
468Subarrays with First Element Minimum
469Subarrays with sum K
470Subset Sum Problem
471Subset XOR
472Substrings of length k with k-1 distinct elements
473Substrings with K Distinct
474Substrings with same first and last characters
475Sum of all substrings of a number
476Sum of Mode
477Sum of Nodes in BST Range
478Sum of nodes on the longest path
479Sum of subarray minimum
480Sum of subarray minimums
481Sum of subarray ranges
482Sum of Subarrays
483Sum Pair closest to target
484Sum Tree
485Sum-string
486Summed Matrix
487Swap and Maximize
488Swap diagonals
489Swap Kth nodes from ends
490Symmetric Tree
491The Celebrity Problem
492The Knight's tour problem
493The Painter's Partition Problem-II
494The Palindrome Pattern
495Toeplitz matrix
496Top K Frequent in Array
497Top View of Binary Tree
498Topological sort
499Total count
500Total Decoding Messages
501Trail of ones
502Transpose of Matrix
503Trapping Rain Water
504Travelling Salesman Problem
505Tree Boundary Traversal
506Triplet Family
507Two Smallests in Every Subarray
508Two Sum - Pair with Given Sum
509Two Swaps
510Tywin's War Strategy
511Undirected Graph Cycle
512Union of Arrays with Duplicates
513Union of Two Sorted Arrays with Distinct Elements
514Unique K-Number Sum
515Unique Number I
516Unique Number II
517Unique Number III
518Unique Paths in a Grid
519Validate an IP Address
520Vertical Tree Traversal
521Vertical Width of a Binary Tree
522Walls Coloring II
523Ways to Reach the n'th Stair
524Ways To Tile A Floor
525Weighted Job Scheduling
526Wildcard Pattern Matching
527Word Break
528Word Search
529XOR Linked List
530XOR Pairs less than K
531ZigZag Tree Traversal