GFG-POTD
Contribute
  • GFG Problem Of The Day
  • Solutions for 2023
    • 06-2023(june)
      • 01. Topological sort
    • 06-2023(june)
      • 02. Santa Banta
    • 06-2023(june)
      • 03. Find Maximum Equal sum of Three Stacks
    • 06-2023(june)
      • 04. Reversing the Equation
    • 06-2023(june)
      • 05. Find the Closest Element in BST
    • 06-2023(june)
      • 06. Finding Predecessor and Successor in a Binary Search Tree
    • 06-2023(june)
      • 07 Least Prime Factor
    • 06-2023(june)
      • 08. Finding the Kth Permutation
    • 06-2023(june)
      • 09. Permutations of a given string
    • 06-2023(june)
      • 10. Arranging the Array
    • 06-2023(june)
      • 11. Adding Ones
    • 06-2023(june)
      • 12. Rod Cutting
    • 06-2023(june)
      • 13. K Largest Elements
    • 06-2023(june)
      • 14. Maximum Diamonds
    • 06-2023(june)
      • 15. Longest Palindrome in a String
    • 06-2023(june)
      • 16. Minimum Time
    • 06-2023(june)
      • 17. Queue Operations
    • 06-2023(june)
      • 18. Ticket Counter
    • 06-2023(june)
      • 19. Rearranging an Array with O(1) Extra Space
    • 06-2023(june)
      • 20. Matchsticks Game
    • 06-2023(june)
      • 21. Reverse Coding
    • 06-2023(june)
      • 22. Lemonade Change
    • 06-2023(june)
      • 23. Task Scheduler
    • 06-2023(june)
      • 24. Prefix Match with Other Strings
    • 06-2023(june)
      • 25. Unique Rows in Boolean Matrix
    • 06-2023(june)
      • 26. nCr (Combination)
    • 06-2023(june)
      • 27. Union of Two Linked Lists
    • 06-2023(june)
      • 28. Maximum Depth of Binary Tree
    • 06-2023(june)
      • 29. Next Happy Number
    • 06-2023(june)
      • 30. Is Binary Number Multiple of 3
    • JUNE - 2023
    • 07-2023(july)
      • 01. Number of 1 Bits
    • 07-2023(july)
      • 02. Copy Set Bits in Range
    • 07-2023(july)
      • 03. Maximum Index
    • 07-2023(july)
      • 04. Count the subarrays having product less than k
    • 07-2023(july)
      • 05. Stock buy and sell II
    • 07-2023(july)
      • 06. Quick Sort
    • 07-2023(july)
      • 07. Merge Without Extra Space
    • 07-2023(july)
      • 08. Find triplets with zero sum
    • 07-2023(july)
      • 09. Smallest Positive missing number
    • 07-2023(july)
      • 10. Transpose of Matrix
    • 07-2023(july)
      • 11. Find kth element of spiral matrix
    • 07-2023(july)
      • 12. Power Of Numbers
    • 07-2023(july)
      • 13. Unique Number of Occurrences
    • 07-2023(july)
      • 14. Implement two stacks in an array
    • 07-2023(july)
      • 15. Delete middle element of a stack
    • 07-2023(july)
      • 16. Queue Reversal
    • 07-2023(july)
      • 17. First non-repeating character in a stream
    • 07-2023(july)
      • 18. Longest Repeating Subsequence
    • 07-2023(july)
      • 19. Longest Palindromic Subsequence
    • 07-2023(july)
      • 20. Non Repeating Character
    • 07-2023(july)
      • 21. Reverse a Linked List in groups of given size
    • 07-2023(july)
      • 22. Remove duplicates from an unsorted linked list
    • 07-2023(july)
      • 23. Given a linked list of 0s, 1s and 2s, sort it.
    • 07-2023(july)
      • 24. Right View of Binary Tree
    • 07-2023(july)
      • 25. Level order traversal in spiral form
    • 07-2023(july)
      • 26. Kth Ancestor in a Tree
    • 07-2023(july)
      • 27. Heap Sort
    • 07-2023(july)
      • 28. Lowest Common Ancestor in a BST
    • 07-2023(july)
      • 29. Median of BST
    • 07-2023(july)
      • 30. Inorder Successor in BST
    • 07-2023(july)
      • 31. BFS of graph
    • JULY - 2023
    • 08-2023(aug)
      • 01. DFS of graph
    • 08-2023(aug)
      • 02. Shortest Source to Destination Path
    • 08-2023(aug)
      • 03. Shortest Path in Directed Acyclic Graph
    • 08-2023(aug)
      • 04. Reverse a Stack
    • 08-2023(aug)
      • 05. Chocolate Distribution Problem
    • 08-2023(aug)
      • 06. String Permutations
    • 08-2023(aug)
      • 07. Solve the Sudoku
    • 08-2023(aug)
      • 08. Fraction pairs with sum 1
    • 08-2023(aug)
      • 09. Largest Prime Factor
    • 08-2023(aug)
      • 10. Longest Common Subsequence
    • 08-2023(aug)
      • 11.Coin Change
    • 08-2023(aug)
      • 12. Longest Increasing Subsequence
    • 08-2023(aug)
      • 13. Nth Fibonacci Number
    • 08-2023(aug)
      • 14. Non Repeating Numbers
    • 08-2023(aug)
      • 15. Flip Bits
    • 08-2023(aug)
      • 16. Nth Catalan Number
    • 08-2023(aug)
      • 17. Next Smallest Palindrome
    • 08-2023(aug)
      • 18. Leaders in an array
    • 08-2023(aug)
      • 19. Subarray with given sum
    • 08-2023(aug)
      • 20. Number of occurrence
    • 08-2023(aug)
      • 21. Surround the 1's
    • 08-2023(aug)
      • 22. Make Matrix Beautiful
    • 08-2023(aug)
      • 23. Find the string in grid
    • 08-2023(aug)
      • 24. Multiply two strings
    • 08-2023(aug)
      • 25. Palindrome String
    • 08-2023(aug)
      • 26. Longest K unique characters substring
    • 08-2023(aug)
      • 27. Reverse a String
    • 08-2023(aug)
      • 28. Remove duplicate element from sorted Linked List
    • 08-2023(aug)
      • 29. Delete nodes having greater value on right
    • 08-2023(aug)
      • 30. Delete a Node in Single Linked List
    • 08-2023(aug)
      • 31. AVL Tree Deletion
    • August - 2023
    • 09-2023(sep)
      • 01. Leftmost and rightmost nodes of binary tree
    • 09-2023(sep)
      • 02. Leaf under budget
    • 09-2023(sep)
      • 03. Check if Tree is Isomorphic
    • 09-2023(sep)
      • 04. Replace O's with X's
    • 09-2023(sep)
      • 05. Print adjacency list
    • 09-2023(sep)
      • 06. Mother Vertex
    • 09-2023(sep)
      • 07. Minimum Multiplications to reach End
    • 09-2023(sep)
      • 08. Binary Tree to BST
    • 09-2023(sep)
      • 09. Kth Largest Element in BST
    • 09-2023(sep)
      • 10. Insert a node in a BST
    • 09-2023(sep)
      • 11. Lucky Numbers
    • 09-2023(sep)
      • 12. Perfect Numbers
    • 09-2023(sep)
      • 13. Largest number possible
    • 09-2023(sep)
      • 14. Perfect Sum Problem
    • 09-2023(sep)
      • 15. Partition Equal Subset Sum
    • 09-2023(sep)
      • 16. Count Number of Hops
    • 09-2023(sep)
      • 17. Print first n Fibonacci Numbers
    • 09-2023(sep)
      • 18. Power of 2
    • 09-2023(sep)
      • 19. Find first set bit
    • 09-2023(sep)
      • 20. Rotate Bits
    • 09-2023(sep)
      • 21. Stickler Thief
    • 09-2023(sep)
      • 22. First and Last Occurrences of x
    • 09-2023(sep)
      • 23. Equilibrium Point
    • 09-2023(sep)
      • 24. Find duplicates in an array
    • 09-2023(sep)
      • 25. Maximum Sum Combination
    • 09-2023(sep)
      • 26. Find All Four Sum Numbers
    • 09-2023(sep)
      • 27. Find the closest pair from two arrays
    • 09-2023(sep)
      • 28. Wave Array
    • 09-2023(sep)
      • 29. Number Of Enclaves
    • 09-2023(sep)
      • 30. Boolean Matrix
    • September - 2023
    • 10-2023(oct)
      • 1. Boundary Traversal of Matrix
    • 10-2023(oct)
      • 2. Number of Distinct Subsequences
    • 10-2023(oct)
      • 3. Column Name from a Given Column Number
    • 10-2023(oct)
      • 4. Roman Number to Integer
    • 10-2023(oct)
      • 5. Count number of substrings
    • 10-2023(oct)
      • 6. Reverse alternate nodes in Link List
    • 10-2023(oct)
      • 7. Pairwise swap elements of a linked list
    • 10-2023(oct)
      • 8. Insert in a Sorted List
    • 10-2023(oct)
      • 9. Height of Binary Tree
    • 10-2023(oct)
      • 10. Nodes at Given Distance in Binary Tree
    • 10-2023(oct)
      • 11. Check for Balanced Tree
    • 10-2023(oct)
      • 12. Duplicate subtree in Binary Tree
    • 10-2023(oct)
      • 13. Floor in BST
    • 10-2023(oct)
      • 14. Find Common Nodes in two BSTs
    • 10-2023(oct)
      • 15. Normal BST to Balanced BST
    • 10-2023(oct)
      • 16. Making A Large Island
    • 10-2023(oct)
      • 17. Transitive closure of a Graph
    • 10-2023(oct)
      • 18. Eventual Safe States
    • 10-2023(oct)
      • 19. Level of Nodes
    • 10-2023(oct)
      • 20. Form a number divisible by 3 using array digits
    • 10-2023(oct)
      • 21. Sum of all divisors from 1 to n
    • 10-2023(oct)
      • 22. Number of Paths
    • 10-2023(oct)
      • 23. Maximum sum increasing subsequence
    • 10-2023(oct)
      • 24. Palindromic Partitioning
    • 10-2023(oct)
      • 25. Knapsack with Duplicate Items
    • 10-2023(oct)
      • 26. Minimum Operations
    • 10-2023(oct)
      • 27. Minimum Deletions
    • 10-2023(oct)
      • 28. Bleak Numbers
    • 10-2023(oct)
      • 29. Check whether K-th bit is set or not
    • 10-2023(oct)
      • 30. Sum of XOR of all pairs
    • 10-2023(oct)
      • 31. Move all zeroes to the end of the array
    • October - 2023
    • 11-2023(nov)
      • 01. Frequencies of Limited Range Array Elements
    • 11-2023(nov)
      • 02. Minimum Distance Between Two Numbers
    • 11-2023(nov)
      • 03. Pythagorean Triplet
    • 11-2023(nov)
      • 04. Find Transition Point
    • 11-2023(nov)
      • 05. Top K Frequent Elements in Array
    • 11-2023(nov)
      • 06. Letters Collection
    • 11-2023(nov)
      • 07. Sum of Upper and Lower Triangles
    • 11-2023(nov)
      • 08. Print Matrix in Snake Pattern
    • 11-2023(nov)
      • 09. Predict the Column
    • 11-2023(nov)
      • 10. Number following a pattern
    • 11-2023(nov)
      • 11. Isomorphic Strings
    • 11-2023(nov)
      • 12. Check if string is rotated by two places
    • 11-2023(nov)
      • 13. Shortest Common Supersequence
    • 11-2023(nov)
      • 14. Check if strings are rotations of each other or not
    • 11-2023(nov)
      • 15. Better String
    • 11-2023(nov)
      • 16. Find the String
    • 11-2023(nov)
      • 17. Binary Tree to CDLL
    • 11-2023(nov)
      • 18. Reverse a Doubly Linked List
    • 11-2023(nov)
      • 19. Intersection of two sorted Linked lists
    • 11-2023(nov)
      • 20. K Sum Paths
    • 11-2023(nov)
      • 21. Determine if Two Trees are Identical
    • 11-2023(nov)
      • 22. Symmetric Tree
    • 11-2023(nov)
      • 23. AVL Tree Insertion
    • 11-2023(nov)
      • 24. Pascal Triangle
    • 11-2023(nov)
      • 25. Shuffle integers
    • 11-2023(nov)
      • 26. Print Pattern
    • 11-2023(nov)
      • 27. Detect Cycle using DSU
    • 11-2023(nov)
      • 28. Sum of Dependencies in a Graph
    • 11-2023(nov)
      • 29. Euler Circuit and Path
    • 11-2023(nov)
      • 30. Shortest path from 1 to n
    • November - 2023
    • 12-2023(dec)
      • 01. Check whether BST contains Dead End
    • 12-2023(dec)
      • 02. Inorder Traversal and BST
    • 12-2023(dec)
      • 03. Brothers From Different Roots
    • 12-2023(dec)
      • 04. Sum-string
    • 12-2023(dec)
      • 05. Minimize the Heights II
    • 12-2023(dec)
      • 06. How Many X's?
    • 12-2023(dec)
      • 07. Number of subarrays with maximum values in given range
    • 12-2023(dec)
      • 08. Transform to Prime
    • 12-2023(dec)
      • 09. Smith Number
    • 12-2023(dec)
      • 10. Subarray with 0 sum
    • 12-2023(dec)
      • 11. Max Sum Subarray of size K
    • 12-2023(dec)
      • 12. Gold Mine Problem
    • 12-2023(dec)
      • 13. Consecutive 1's not allowed
    • 12-2023(dec)
      • 14. Painting the Fence
    • 12-2023(dec)
      • 15. Reach the Nth point
    • 12-2023(dec)
      • 16. String's Count
    • 12-2023(dec)
      • 17. Max Sum without Adjacents
    • 12-2023(dec)
      • 18. Game of XOR
    • 12-2023(dec)
      • 19. Rightmost different bit
    • 12-2023(dec)
      • 20. Modified Game of Nim
    • 12-2023(dec)
      • 21. Candy
    • 12-2023(dec)
      • 22. Maximum Meetings in One Room
    • 12-2023(dec)
      • 23. Count More than n/k Occurrences
    • 12-2023(dec)
      • 24. Buy Maximum Stocks if i stocks can be bought on i-th day
    • 12-2023(dec)
      • 25. Determinant of a Matrix
    • 12-2023(dec)
      • 26. Largest rectangular sub-matrix whose sum is 0
    • 12-2023(dec)
      • 27. Anti Diagonal Traversal of Matrix
    • 12-2023(dec)
      • 28. Wildcard String Matching
    • 12-2023(dec)
      • 29. Check if a string is repetition of its substring of k-length
    • 12-2023(dec)
      • 30. Winner of an Election
    • 12-2023(dec)
      • 31. New Year Resolution
    • December - 2023
  • Solutions for 2024
    • 01-2024(jan)
      • 01. Array Pair Sum Divisibility Problem
    • 01-2024(jan)
      • 02. Largest Sum Subarray of Size at least K
    • 01-2024(jan)
      • 03. Smallest window containing 0, 1 and 2
    • 01-2024(jan)
      • 04. Find element occurring once when all others are present thrice
    • 01-2024(jan)
      • 05. Count Possible Ways to Construct Buildings
    • 01-2024(jan)
      • 06. Techfest and the Queue
    • 01-2024(jan)
      • 07 - Split Array Largest Sum
    • 01-2024(jan)
      • 08. Merge 2 sorted linked lists in reverse order
    • 01-2024(jan)
      • 09. Search Pattern (KMP-Algorithm)
    • 01-2024(jan)
      • 10. Longest subarray with sum divisible by K
    • 01-2024(jan)
      • 11. Remove K Digits
    • 01-2024(jan)
      • 12. Reverse First K elements of Queue
    • 01-2024(jan)
      • 13. Insertion Sort for Singly Linked List
    • 01-2024(jan)
      • 14. Find duplicate rows in a binary matrix
    • 01-2024(jan)
      • 15. Grinding Geek
    • 01-2024(jan)
      • 16. Sequence of Sequence
    • 01-2024(jan)
      • 17 - All Unique Permutations of an array
    • 01-2024(jan)
      • 18. Water the plants
    • 01-2024(jan)
      • 19. Top k numbers in a stream
    • 01-2024(jan)
      • 20. Distribute candies in a binary tree
    • 01-2024(jan)
      • 21. Vertex Cover
    • 01-2024(jan)
      • 22. Paths from root with a specified sum
    • 01-2024(jan)
      • 23. Course Schedule
    • 01-2024(jan)
      • 24. Is it a tree ?
    • 01-2024(jan)
      • 25. Shortest Prime Path
    • 01-2024(jan)
      • 26. Fractional Knapsack
    • 01-2024(jan)
      • 27. Brackets in Matrix Chain Multiplication
    • 01-2024(jan)
      • 29. Count digit groupings of a number
    • 01-2024(jan)
      • 30. LCS of three strings
    • 01-2024(jan)
      • 31. Insert and Search in a Trie
    • January - 2024
    • 02-2024(feb)
      • 01. Panagram Checking
    • 02-2024(feb)
      • 02. Implement Atoi
    • 02-2024(feb)
      • 03. Decimal Equivalent of Binary Linked List
    • 02-2024(feb)
      • 05. Sorted insert for circular linked list
    • 02-2024(feb)
      • 06. Count the nodes at distance K from leaf
    • 02-2024(feb)
      • 07. Min distance between two given nodes of a Binary Tree
    • 02-2024(feb)
      • 08. Check if all leaves are at the same level
    • 02-2024(feb)
      • 09. Check for Children Sum Property in a Binary Tree
    • 02-2024(feb)
      • 10. Number of paths in a matrix with k coins
    • 02-2024(feb)
      • 11. Recamans sequence
    • 02-2024(feb)
      • 12. Recursive sequence
    • 02-2024(feb)
      • 14. Find all Critical Connections in the Graph
    • 02-2024(feb)
      • 15. Count all Possible Path
    • 02-2024(feb)
      • 16. Flatten BST to sorted list
    • 02-2024(feb)
      • 17. Does array represent Heap
    • 02-2024(feb)
      • 18. Sum of leaf nodes in BST
    • 02-2024(feb)
      • 19. Game with String
    • 02-2024(feb)
      • 20. Word Break
    • 02-2024(feb)
      • 21. Boolean Parenthesization
    • 02-2024(feb)
      • 22. Distinct occurrences
    • 02-2024(feb)
      • 23. Buy and Sell a Share at most twice
    • 02-2024(feb)
      • 24. Maximum Sum Problem
    • 02-2024(feb)
      • 25. Reach a given score
    • 02-2024(feb)
      • 26. Power Set
    • 02-2024(feb)
      • 27. Play With OR
    • 02-2024(feb)
      • 28. Check if a number is divisible by 8
    • 02-2024(feb)
      • 29. Sum of bit differences
    • February 2024
    • 03-2024(march)
      • 01. Peak element
    • 03-2024(march)
      • 02. First element to occur k times
    • 03-2024(march)
      • 03. Largest Number formed from an Array
    • 03-2024(march)
      • 04. Swap the array elements
    • 03-2024(march)
      • 05. Maximum Index
    • 03-2024(march)
      • 06. Search Pattern (Rabin-Karp Algorithm)
    • 03-2024(march)
      • 07. Longest repeating and non-overlapping substring
    • 03-2024(march)
      • 08. Check if frequencies can be equal
    • 03-2024(march)
      • 09. Find the N-th character
    • 03-2024(march)
      • 10. Remove all duplicates from a given string
    • 03-2024(march)
      • 11. Count pairs Sum in matrices
    • 03-2024(march)
      • 14. Largest subsquare surrounded by X
    • 03-2024(march)
      • 15. Linked List that is Sorted Alternatingly
    • 03-2024(march)
      • 16. Delete without head pointer
    • 03-2024(march)
      • 17. Count Pairs whose sum is equal to X
    • 03-2024(march)
      • 18. Level order traversal
    • 03-2024(march)
      • 20. Sum of nodes on the longest path from root to leaf node
    • 03-2024(march)
      • 21. ZigZag Tree Traversal
    • 03-2024(march)
      • 21. Diagonal sum in binary tree
    • 03-2024(march)
      • 23. Fibonacci series up to Nth term
    • 03-2024(march)
      • 24. Insert an Element at the Bottom of a Stack
    • 03-2024(march)
      • 26. Additive sequence
    • 03-2024(march)
      • 27. Find shortest safe route in a matrix
    • 03-2024(march)
      • 28. City With the Smallest Number of Neighbors at a Threshold Distance
    • 03-2024(march)
      • 29. Euler Circuit in an Undirected Graph
    • 03-2024(march)
      • 30. Minimum element in BST
    • 03-2024(march)
      • 31. Closest Neighbour in BST
    • March 2024
    • 04-2024(april)
      • 01. Pairs violating the BST property
    • 04-2024(april)
      • 04. Sum of all substrings of a number
    • 04-2024(april)
      • 05. Strictly Increasing Array
    • 04-2024(april)
      • 06. Count ways to N'th Stair
    • 04-2024(april)
      • 07. Maximize dot product
    • 04-2024(april)
      • 08. Optimal Strategy For A Game
    • 04-2024(april)
      • 09. Minimum Points To Reach Destination
    • 04-2024(april)
      • 10. Party of Couples
    • 04-2024(april)
      • 11. Gray to Binary equivalent
    • 04-2024(april)
      • 12. Sum of Products
    • 04-2024(april)
      • 13. Reverse Bits
    • 04-2024(april)
      • 14. Xoring and Clearing
    • 04-2024(april)
      • 15. Count the elements
    • 04-2024(april)
      • 17. Count Pairs in an Array
    • 04-2024(april)
      • 18. Count Pairs in an Array
    • 04-2024(april)
      • 19. Find missing in second array
    • 04-2024(april)
      • 20. Union of Two Sorted Arrays
    • 04-2024(april)
      • 22. Row with minimum number of 1's
    • 04-2024(april)
      • 23. Rohan's Love for Matrix
    • 04-2024(april)
      • 28. Delete Middle of Linked List
    • 04-2024(april)
      • 29. Remove every kth node
    • April 2024
    • 05-2024(may)
      • 03. K distance from root
    • 05-2024(may)
      • 06. Print all nodes that don't have sibling
    • 05-2024(may)
      • 07. Reverse Level Order Traversal
    • 05-2024(may)
      • 17. Find Pair Given Difference
    • 05-2024(may)
      • 18. Find the Highest number
    • 05-2024(may)
      • 19. Find the closest number
    • 05-2024(may)
      • 20. Modular Exponentiation for large numbers
    • 05-2024(may)
      • 23. K-Palindrome
    • 05-2024(may)
      • 24. Partitions with Given Difference
    • 05-2024(may)
      • 26. Minimum Cost To Make Two Strings Identical
    • 05-2024(may)
      • 28. Minimum cost to fill given weight in a bag
    • 06-2024(june)
      • 01. Odd Even Problem
    • 06-2024(june)
      • 02. Construct list using given q XOR queries
    • 06-2024(june)
      • 03. Trail of ones
    • 06-2024(june)
      • 29. Identical Linked Lists
    • 06-2024(june)
      • 30. Delete node in Doubly Linked List
    • 07-2024(july)
      • 03. Remove all occurences of duplicates in a linked list
  • helper
    • template
Powered by GitBook
On this page

Was this helpful?

  1. Solutions for 2024

03-2024(march)

07. Longest repeating and non-overlapping substring
Previous06. Search Pattern (Rabin-Karp Algorithm)Next07. Longest repeating and non-overlapping substring

Last updated 1 year ago

Was this helpful?