DDSA
POTD Solutions

GeeksforGeeks Java Solutions

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

530
Solved
Advertisement

530 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
201Level Order in spiral form
202Level order traversal
203Lexicographically Largest String After Deleting K Characters
204Linked List Group Reverse
205Linked List Matrix
206Linked list of strings forms a palindrome
207Longest alternating subsequence
208Longest Bounded-Difference Subarray
209Longest Common Increasing Subsequence
210Longest Common Prefix of Strings
211Longest Common Subsequence
212Longest Common Substring
213Longest Consecutive Subsequence
214Longest Increasing Subsequence
215Longest Palindrome in a String
216Longest Palindromic Subsequence
217Longest Periodic Proper Prefix
218Longest Prefix Suffix
219Longest Span in two Binary Arrays
220Longest String Chain
221Longest Subarray Length
222Longest subarray with Atmost two distinct integers
223Longest Subarray with Majority Greater than K
224Longest Subarray with Sum K
225Longest substring with distinct characters
226Longest Substring with K Uniques
227Longest valid Parentheses
228Look and Say Pattern
229Lowest Common Ancestor in a BST
230LRU Cache
231Majority Element
232Majority Element II
233Majority Vote
234Make array elements unique
235Make Binary Tree From Linked List
236Make Matrix Beautiful
237Make Strings Equal
238Matrix Chain Multiplication
239Max Circular Subarray Sum
240Max DAG Edges
241Max distance between same elements
242Max min Height
243Max of min for every window size
244Max rectangle
245Max Score from Subarray Mins
246Max sum in the configuration
247Max Sum Increasing Subsequence
248Max sum path in two arrays
249Max Sum Subarray of size K
250Max Xor Subarray of size K
251Maximise String Score
252Maximize Array Value After Rearrangement
253Maximize median after doing k addition operation
254Maximize Number of 1's
255Maximize partitions in a String
256Maximize The Cut Segments
257Maximize the minimum difference between k elements
258Maximum Connected group
259Maximum Difference
260Maximum Non-Adjacent Nodes Sum
261Maximum Non-Overlapping Odd Palindrome Sum
262Maximum number of overlapping Intervals
263Maximum of minimum for every window size
264Maximum path sum
265Maximum path sum from any node
266Maximum People Visible in a Line
267Maximum Product Subarray
268Maximum product subset of an array
269Maximum Stone Removal
270Maximum subarray sum 2
271Maximum Sum Combination
272Maximum sum of elements not part of LIS
273Maximum sum of Non-adjacent nodes
274Maximum sum Rectangle
275Maximum XOR of two numbers in an array
276Median in a row-wise sorted Matrix
277Median of BST
278Median of two sorted arrays
279Meeting Rooms
280Meeting Rooms III
281Merge K sorted linked lists
282Merge Sort for Linked List
283Merge two BST 's
284Merge two sorted linked lists
285Merge Without Extra Space
286Middle of a Linked List
287Min Add to Make Parentheses Valid
288Min Chars to Add for Palindrome
289Min Cost Climbing Stairs
290Minimal Cost
291Minimize the Heights I
292Minimize the Heights II
293Minimum Cost of ropes
294Minimum Cost Path
295Minimum cost to connect all houses in a city
296Minimum Cost to cut a board into squares
297Minimum Cost to Cut a Stick of length N
298Minimum Cost to Merge Stones
299Minimum days to make M bouquets
300Minimum Deletions
301Minimum Jumps
302Minimum K Consecutive Bit Flips
303Minimum number of deletions and insertions
304Minimum Number of Workers
305Minimum Operations to Connect Hospitals
306Minimum Platforms
307Minimum repeat to make substring
308Minimum Steps to Halve Sum
309Minimum sum
310Minimum Weight Cycle
311Minimum Window Subsequence
312Mirror Tree
313Missing And Repeating
314Missing Element in Range
315Missing element of AP
316Missing in Array
317Mobile numeric keypad
318Modify the Array
319Move All Zeroes to End
320Multiply two linked lists
321Multiply two strings
322N meetings in one room
323N-Queen Problem
324nCr
325Nearest multiple of 10
326Nearly sorted
327Next element with greater frequency
328Next Greater Element
329Next Greater Element in Circular Array
330Next Permutation
331Nine Divisors
332Non Repeating Character
333Non-overlapping Intervals
334Not a subset sum
335Nth Natural Number
336Number of BST From Array
337Number of distinct subsequences
338Number of occurrence
339Number of pairs
340Number of paths in a matrix with k coins
341Number of Rectangles in a Circle
342Number of Ways to Arrive at Destination
343Occurence of an integer in a Linked List
344Optimal binary search tree
345Optimal Strategy For A Game
346Overlapping Intervals
347Pair Sum in BST
348Pair with given sum in a sorted array
349Pairs with difference k
350Palindrome Linked List
351Palindrome Sentence
352Palindrome SubStrings
353Parenthesis Checker
354Partition Equal Subset Sum
355Pascal Triangle
356Path With Minimum Effort
357Peak element
358Permutations of a String
359Police and Thieves
360Populate Inorder Successor for all nodes
361Possible Words From Phone Digits
362Postfix Evaluation
363Postorder Traversal
364Power of k in factorial of n
365Powerful Integer
366Predecessor and Successor
367Prime List
368Prime Pair with Target Sum
369Print Anagrams Together
370Print Bracket Number
371Print leaf nodes from preorder traversal of BST
372Product array puzzle
373Pythagorean Triplet
374Queue Reversal
375Quick Sort on Linked List
376Rat in a Maze
377Rat in a Maze Problem - I
378Remaining String
379Remove all occurences of duplicates in a linked list
380Remove BST keys outside given range
381Remove Duplicates
382Remove duplicates in array
383Remove Half Nodes
384Remove loop in Linked List
385Remove the balls
386Reorganize The Array
387Replace O's with X's
388Reverse a Doubly Linked List
389Reverse a linked list
390Reverse an Array
391Reverse Words
392Roman Number to Integer
393Roof Top
394Root to leaf path sum
395Root to Leaf Paths
396Root to leaf paths sum
397Rotate a Linked List
398Rotate and delete
399Rotate Array
400Rotate by 90 degree
401Rotate Deque By K
402Rotten Oranges
403Row with max 1s
404Safe States
405Search in a Row-Column sorted matrix
406Search in a row-wise sorted matrix
407Search in a sorted Matrix
408Search in an almost Sorted Array
409Search in fully rotated sorted 2D matrix
410Search in Rotated Sorted Array
411Search insert position of K in a sorted array
412Search Pattern (KMP-Algorithm)
413Search Pattern (Rabin-Karp Algorithm)
414Second Best Minimum Spanning Tree
415Second Largest
416Segregate 0s and 1s
417Serialize and deserialize a binary tree
418Set Matrix Zeroes
419Set Matrix Zeros
420Shop in Candy Store
421Shortest Common Supersequence
422Shortest Cycle
423Shortest path in Undirected Graph
424Shortest Path in Weighted undirected graph
425Shortest Path Using Atmost One Curved Edge
426Single Number
427Smallest distinct window
428Smallest Divisor
429Smallest number
430Smallest Positive Missing
431Smallest Positive Missing Number
432Smallest range in K lists
433Smallest window containing all characters
434Smallest window in a string containing all the characters of another string
435Solve the Sudoku
436Sort 0s, 1s and 2s
437Sort a k sorted doubly linked list
438Sort a linked list of 0s, 1s and 2s
439Sort by Absolute Difference
440Sort in specific order
441Sort the given array after applying the given equation
442Sorted and Rotated Minimum
443Sorted subsequence of size 3
444Sorting Elements of an Array by Frequency
445Spirally traversing a matrix
446Split an array into two equal Sum subarrays
447Split array in three equal sum subarrays
448Split Array Largest Sum
449Split Array Subsequences
450Split Linked List Alternatingly
451Split the Array
452Square root of a number
453Stickler Thief
454Stickler Thief II
455Stock Buy and Sell – Max 2 Transactions Allowed
456Stock Buy and Sell – Max K Transactions Allowed
457Stock Buy and Sell – Max one Transaction Allowed
458Stock Buy and Sell – Multiple Transaction Allowed
459Stock Buy and Sell with Cooldown
460Stock span problem
461Stream First Non-repeating
462String stack
463Strings Rotations of Each Other
464Sub-arrays with equal number of occurences
465Subarray range with given sum
466Subarrays With At Most K Distinct Integers
467Subarrays with First Element Minimum
468Subarrays with sum K
469Subset Sum Problem
470Subset XOR
471Substrings of length k with k-1 distinct elements
472Substrings with K Distinct
473Substrings with same first and last characters
474Sum of all substrings of a number
475Sum of Mode
476Sum of Nodes in BST Range
477Sum of nodes on the longest path
478Sum of subarray minimum
479Sum of subarray minimums
480Sum of subarray ranges
481Sum of Subarrays
482Sum Pair closest to target
483Sum Tree
484Sum-string
485Summed Matrix
486Swap and Maximize
487Swap diagonals
488Swap Kth nodes from ends
489Symmetric Tree
490The Celebrity Problem
491The Knight's tour problem
492The Painter's Partition Problem-II
493The Palindrome Pattern
494Toeplitz matrix
495Top K Frequent in Array
496Top View of Binary Tree
497Topological sort
498Total count
499Total Decoding Messages
500Trail of ones
501Transpose of Matrix
502Trapping Rain Water
503Travelling Salesman Problem
504Tree Boundary Traversal
505Triplet Family
506Two Smallests in Every Subarray
507Two Sum - Pair with Given Sum
508Two Swaps
509Tywin's War Strategy
510Undirected Graph Cycle
511Union of Arrays with Duplicates
512Union of Two Sorted Arrays with Distinct Elements
513Unique K-Number Sum
514Unique Number I
515Unique Number II
516Unique Number III
517Unique Paths in a Grid
518Validate an IP Address
519Vertical Tree Traversal
520Vertical Width of a Binary Tree
521Walls Coloring II
522Ways to Reach the n'th Stair
523Ways To Tile A Floor
524Weighted Job Scheduling
525Wildcard Pattern Matching
526Word Break
527Word Search
528XOR Linked List
529XOR Pairs less than K
530ZigZag Tree Traversal