Starting 100 Days of Code
Weekdays: Work on DP and Data Structures on Hackerrank
Weekends: Web Devlopment
21st - Variations of LIS - Longest Increasing Subsequence - LIS,largest Divisible subset,russian Dolls
51st - Minimum Absolute Difference,Sort integers by the number of 1 bits,find disappeared Number(Cycle sort)
53rd - 3Sum,Combinations using recursion - Letter Combinations of a Phone Number,Number of Dice Rolls With Target Sum
65th - All Paths From Source to Target - find all paths and when current element becomes n-1 end it, Beautiful arrangement - Going from backward helps as it prunes more cases
66th - Path with Maximum Gold - Backtrack along all starting points, Tug of War - Use Target sum effectively(Geeks for Geeks question)
67th - Parsing a boolean Expression - Try using level for each '(' ')' and parse for each expression between them. base condition return whenever you find t or f
68th - Special Binary Strings - equal to valid parenthesis, sort valid paranthesis in reverse order and join.
69th - Permutation Sequence - recurisve solution give TLE try to find mathematical approach. each digit will have a region hint: nn-1n-2....
71st - Basic Calculator 2 - Same as but handle * and / but popping last element from stack, Integer to Number - Find pattern in each three digits of number also remember to handle edge cases
85th - Linked List - Remove nth node from end - move a pointer n times then start a prev pointer take care of edge cases
86th - Linked List - Cycle 2 - floyd's algorithm - find relationship between distance moved by both slow and fast pointer
87th - Linked List - Flatten a Multilevel Doubly Linked List - take care of the case when last element has a child
91st - Nearest greater to left, Online stock span - whenever nested loops are there and inner loop(j) depends on outer loop(i) a better solution can be implemented using stack
92nd - Maximum Area in Histogram - think of finding Nearest smallest from left then from right as well
93rd - Maximum Area In Binary Matrix - think of compressing the 2D matrix into 1D, do not buildings need a ground to stand on ;)
94th - Water Trapping Problem - For each building find its left and right max, then think how much water will be above this building , Min Stack - using supporting stack and 2x-ME method
95th - Heap - insertion and deletion and heapify method - use heap when sorting needed and K is given it reduces time complexity to nO(logk)
98th - Minimum Cost to Merge Stones - Greedy solution done but not optimized :/ ->Need to think differently now
99th - Failed attempt to understand above ques DP solution will look again after sometime with fresh outlook. Sliding window concepts
100th - Sliding Window Maximum - for current element, if this element is greater than back of queue then keep on popping elements. All elements after this should be added to queue
101th - Count of occurence of anagrams - use sliding map, make second string as hashmap, then slide a window and if all characters in hashmap is zero then anangram found else not.
Longest substring without Repeating characters - instead of storing each character count better method would be to store index and to check that index lies between left and right pointers
Longest substring with at least k repeating characters - tried 2 methods now trying to understand the sliding window approach, for D&C - take char which are less than k and then partition string based on this.
- Used sliding window for this here it is - first find the total number of unique characters then loop over the string and find the max substring with only the curr no. of unique characters and each time update the max variable