🚀 Problem of the Day: Sort Jumbled on LeetCode.
Just tackled the "Sort by Mapped Values"problem with an optimized approach using custom sorting with lambdas in C
Follow for more daily DSA challenges and coding insights for FAANG! #LeetCode#DSA#FAANGPrep#Coding#TechTwitter
#leetcode1700 potd (08/04/24)
What I learned today:- when to use stack and queue
Approach:-without using stack,count no of 0&1 and traverse sandwiches array and decrease the count of 0&1 when it equals to zero then return length - index value and lastly return 0
Asked by #amazon
What i learned today :-
Potd(#Leetocde1249 asked by #amazon)
Learning part:- how to use unordered set into stack to store the index which need to be excluded.
Approach :- push ( index into set and pop when ) if not empty ,else push into set and then take string ans and insert
What i learned today :-
Potd(#Leetocde1614 asked by #amazon#facebook)
Learning part:-stack can be used here
Approach :- without stack :-take a empty string result when find char having result.back() 32 or -32 equals to char ch then pop and if not then push into result string .
What i learned today :-
Potd(#Leetocde1614 asked by #amazon#facebook#intel#bloomberg)
Learning part:- why stack is used here
Approach :- push for( and pop for ) and find max of ans and stack size
:-use of 2 var for ( count ) count-- return the max of ans and count
What i learned today :-
Potd(#Leetocde79 asked by #amazon#intuitive#apple#microsoft)
Learning part:- How to apply backtracking
Approach :- find the first index of word in 2d matrix and then call for the backtracking process for all the other four directions at that index.
What i learned today :-
Potd(#Leetocde205 asked by #amazon#uber#myntra)
Learning part:- use of map to map the char to char variables
Approach :- put both string to two diff map as char to char and check char is present or not if yes then check ✅ not link to more than 1char.
What i learned today :-
Potd(#Leetocde58 asked by #amazon)
Learning part:- use of stl string.find_last_not_of(' ').
Approach :- start traverse the string from the back till get some characters and again traverse and count also till don't get spaces
What i learned today :-
Potd(#Leetocde2444asked by #amazon)
Learning part:-derive a general formula of possible to get the ans using dry and run.
Approach :- storing the index of min max and culprit value for each index and get the ans using sliding window
What i learned today :-
Potd(#Leetocde992asked by #amazon)
Learning part:- call two times sliding window for k and k-1.
Approach :- same pattern of sliding window having k distinct integers but in this question call the noofsubarry function twice
What i learned today:-problem of the day(#leetcode2962 asked by Amazon)
Approach:-
1. Better -Using sliding window using nested while loop with o(2n)
2. Optimal - extra vector of given length k,store index of max no. Time and space Complexity o(n) ,o(n).
leetcode.com/problems/count-…
What i learned today:-(#leetcode2958 asked by #flipkart)
Approach:-1. Brute force with o(n^2)
2. Better approach -Using sliding window using nested while loop with o(2n)
3. Optimal - using sliding window without while loop ,I use If condition o(n).
leetcode.com/problems/length…
What I learned today:-(potd #leetcode 41 asked by #meta)
Approach:-using extra array and indexing method.
Optimal :-indexing bcz its take o(1) space
Learning part:-always try to think about index put them -ve on as per qsn , when numberis given between range 1 to n.
#placement
What i learned today :- potd(#leetcode All duplicates in array, asked By #Meta#amazon)
Approach:-take give no as index and mark them - ve and if any index is - ve already dy then push that element in new array and return the array as ans.
All thanks to @CSwithMIK bhaiya❤️
What i learned today :-(#leetcode287) asked By #amazon so many times
It can be solve by using various approaches but restrictions is there that no extra space and no modifications of array value
Approach :Use #Hare and #tortoise method.
Learn part :use of slow nd fast pointer
What i learned today :-potd(# #leetcode143 asked By #Meta
I solve using 3approach, stack, reverse and recursion
Learning part:- for each return part connect the link as per qsn,good to see myself as solving qsn using recursion
What i learned today :-POTD(#Leetocde234 ) asked By #Google.
Solved using two approach
an extra array and recursion
Learning part :- check condition during each return part of recursion
Approach : traverse to the last node and chk condition during return part