6Companies30days


Question logic C
1. Group Anagrams sort each word + maintain a hashmap of strings M
2. Subarray Product Less Than K Two Pointers + count += right - left + 1 M
3. Overlapping Rectangle two rectangles dont overlap when one side is out of reach of other from left & right E
4. UglyNumber 2 Use a set or pq to revaluate the min each time, set.pb(currX {2,3,5} ), set.erase(curr)
DP idea - since each number can be generated from former ugly numbers by multiplying 2,3,5 (maintain pointers at 2,3,5) and increment accordingly
M
5. RunLengthEncoding 2 pointers: r - find similiar items, l - update M
6. GCD Strings str1+str2 == str2+str1 : gcd of strs = gcd of len M
7. MthPosition (K+M-1)%N == 0 ? N : (K+M-1)%N B
8. DecodeWays DP If curr idx valid : numWays[i] += numWays[i+1] :
idx + (idx+1) forms a valid combo : numWays[i] += numWays[i+2]
M
9. ID pattern REDO ?
10. Find max 10 numbers in a list having 10M entries An array of top 10 O
11. Missing Numbers use indices as a measure (-1* if found ) M
12. TotalSquaresChess (n*(n+1)*((2*n)+1))/6 B
13. Decode String Simple Recursion M
14. MinSizeSubarray Classic 2 pointers M
15. ArrayPairs if sum of modulos is div then nums are also div M


References

Arsh Goyal’s GS Sheet