π Solved today's GFG POTD: Count Pairs Divisible By K
π‘ Trick:
Forget the numbers.
Just count the frequency of every remainder and pair complementary remainders.
π₯https://t.co/9dHN0ZaBMx
#GFGPOTD#Hashing#Math#AajKaCode
π Solved today's GFG POTD: Towers Reaching Both Stations
π‘ Trick:
Don't start DFS from every tower.
Start from both stations and traverse in reverse.
π₯ https://t.co/8IpFQZawVj
#GFGPOTD#DFS#Graphs#AajKaCode
π Solved today's GFG POTD: Largest Unblocked Submatrix
π‘ Trick:
Ignore the matrix.
Find the largest gap between blocked rows and blocked columns, then multiply them.
π₯ https://t.co/zVR1W6vgkL
#GFGPOTD#Sorting#Arrays#AajKaCode
π Solved today's GFG POTD: Max Sum Path in Two Arrays
π‘ Trick:
At every common element, choose the path with the larger accumulated sum.
π₯ https://t.co/2p2FZfmf8J
#GFGPOTD#Greedy#TwoPointers#AajKaCode
π Solved today's GFG POTD: Substrings with More 1's than 0's
π‘ Key Observation:
Convert
1 β +1
0 β -1
Then use Prefix Sum + HashMap to count all valid substrings in O(N).
π₯ Watch here: https://t.co/LlEhqTvQzE
#GFGPOTD#PrefixSum#HashMap#AajKaCode
π Solved today's GFG POTD: Ways to Increase LCS by One
π‘ Key Observation:
Split the answer into:
β‘οΈ Prefix LCS
β‘οΈ Inserted Character
β‘οΈ Suffix LCS
This avoids recomputing LCS for every insertion.
π₯ Watch here: https://t.co/SrF0KdkNGc
#GFGPOTD#LCS#DP#AajKaCode
π Solved today's GFG POTD: Check Subset Sum Divisible by K
π‘ Key Observation:
Never store the complete sum.
Store only:
β‘οΈ Sum % K
This reduces the DP state space from exponential to O(N Γ K).
π₯ Watch here: https://t.co/q8ZWm3J4xL
#GFGPOTD#DP#Modulo#AajKaCode
π Solved today's GFG POTD: Max Subarray Sum by Removing At Most One
π‘ Key Idea:
Delete one element and combine:
β‘οΈ Best Left Subarray
β‘οΈ Best Right Subarray
π₯ Watch here: https://t.co/2Zxqnsvey8
#GFGPOTD#Kadane#AajKaCode
π Solved today's GFG POTD: Minimum Insert and Delete to Convert
π‘ The key observation:
Since array b is sorted and distinct, the problem transforms from LCS to LIS!
Complexity:
O(NΓM) β O(N log N)
π₯ Watch here: https://t.co/JwrOOWlZZr
#GFGPOTD#LIS#DSA#AajKaCode
π Solved today's GFG POTD: k Times Appearing Adjacent Two 1's
The key DP insight:
π The current decision depends on the previous bit.
State:
dp[i][prev][k]
π₯ Watch here: https://t.co/q17oUFeeO3
#GFGPOTD#DP#BinaryStrings#AajKaCode
π Solved today's GFG POTD: Ways to Tile the Floor
π‘ Just 2 choices lead to the DP recurrence:
β‘οΈ Horizontal tile
β‘οΈ m Vertical tiles
dp[n] = dp[nβ1] + dp[nβm]
π₯Watch here: https://t.co/awBwfdxOpn
#AajKaCode#GFGPOTD#DP
π Solved today's GFG POTD: Count Matching Subsequences
Learn the Take/Not Take intuition and how Memoization optimizes the solution from exponential recursion to O(N Γ M).
π₯ Watch here: [https://t.co/7X4GxK5yIj]
#GFGPOTD#GeeksforGeeks#DP#DSA#CP#AajKaCode