LC: 88 | Merge Sorted Array
10:49
9 ай бұрын
LC: 1004 | Max Consecutive Ones
11:04
LC: 1492 | The kth Factor of n
6:30
LC: 392 | is Subsequence
8:44
10 ай бұрын
LC:151 | Reverse words in a String
6:37
Пікірлер
@SipunMishra11
@SipunMishra11 22 күн бұрын
Looks like he forget about this account password 😂
@chiragsingh6671
@chiragsingh6671 Ай бұрын
i think 2nd question is somewhat like mergeIntervals , for every ith pair we will see if the jth pair can be merged with it
@iamnoob7593
@iamnoob7593 Ай бұрын
Very good explanation
@iamnoob7593
@iamnoob7593 Ай бұрын
Superb explanation
@sanjayprakash6842
@sanjayprakash6842 Ай бұрын
Great content what ever you said 💯% true m here in Chennai from last 7 months people of chennai is very nice and educated there is no hate for North Indian here even they respect hindi speaking people more what ever we see in media is totally false and fake Tamil people are hard working and honest they are very down-to-earth very helpful no showoff life in Chennai is peaceful you can settle here with family also
@punyajain2450
@punyajain2450 Ай бұрын
in second question, what will be the approach if we can rearrange the elements ?
@yogeshmane9860
@yogeshmane9860 Ай бұрын
😪
@ShrutikaUtsav-ov7kc
@ShrutikaUtsav-ov7kc Ай бұрын
thank you for making this channel
@ashutoshpandey4271
@ashutoshpandey4271 Ай бұрын
Bhaiya what about job losses due to AI and being replaced by AI?
@techiji1645
@techiji1645 2 ай бұрын
where is code
@samakshGoswami-zx8ye
@samakshGoswami-zx8ye 2 ай бұрын
bhaiya konsa pentab and software h , mujhe lena h dsa k notes and question k liye
@praveshkashyap6225
@praveshkashyap6225 3 ай бұрын
Is it in c or c++ language?
@user-mb3mk4on2x
@user-mb3mk4on2x 3 ай бұрын
first question is leetcode 1004 max consecutive ones III. already solved using sliding window.
@biswarupacharjya2258
@biswarupacharjya2258 4 ай бұрын
Very nice explaination
@amansehgal1568
@amansehgal1568 4 ай бұрын
how is kla tencor Chennai?
@ankurdhaka01
@ankurdhaka01 6 ай бұрын
result[0]=1; why you use this??
@b.aditya1933
@b.aditya1933 6 ай бұрын
i did this in question in o(n^2 + m) because of that i am getting time exceed in leetcode algorithm optimisation is very hard
@rajanjaiswal1899
@rajanjaiswal1899 7 ай бұрын
I think First question is of DP and second question is of dfs with memorization. O(N) complexity for both
@user-qs1lh1qv1d
@user-qs1lh1qv1d 7 ай бұрын
can u please provide me pdf of this book
@JainShrayansh
@JainShrayansh 7 ай бұрын
ack
@yogeshjoshi8021
@yogeshjoshi8021 7 ай бұрын
This question has been asked to me in EPAM Company's interview. Thanks Shreyansh for DSA series
@JainShrayansh
@JainShrayansh 7 ай бұрын
thanks
@bhaveshbamhane2259
@bhaveshbamhane2259 7 ай бұрын
But your speaking style is funny 😂
@cricophobiya4178
@cricophobiya4178 7 ай бұрын
from collections import Counter def minimum_window(str1,str2): window="a"*(len(str1)+1) left=0 count=0 hashmap=Counter(str2) for i in range(len(str1)): if str1[i] in hashmap: hashmap [str1[i]]-=1 if hashmap [str1[i]]>=0: count+=1 while count==len(str2): if len(str1[left:i+1]) < len(window): window=str1[left:i+1] if str1[left] in hashmap: hashmap [str1[left]]+=1 if hashmap [str1[left]]>0: count-=1 left+=1 return window str1='ADOBECODEBANC' str2='ABC' print(minimum_window(str1,str2)) str1 = "PRWSOERIUSFK" str2 = "OSU" print(minimum_window(str1,str2))
@nas0208
@nas0208 8 ай бұрын
Just one for loop in the efficient approach.......use one more index say nonzero index.....and make nums(nonzeroindex) = num and nums(i) = 0 .....???
@vipulkohli5245
@vipulkohli5245 8 ай бұрын
Ground to earth
@nitishprasadkushwaha
@nitishprasadkushwaha 8 ай бұрын
if someone needs the code . class Solution { TrieSearch root; public List<List<String>> suggestedProducts(String[] products, String searchWord) { List<List<String>> result = new ArrayList<List<String>>(); root = callFillTrie(products); String prefix=""; for(char c : searchWord.toCharArray()) { List<String> outputforprefix = new ArrayList<String>(); prefix = prefix + c; outputforprefix = searchString(prefix); result.add(outputforprefix); } return result; } public List<String> searchString(String prefix) { TrieSearch searchStartNode = root; List<String> result = new ArrayList<String>(); for (char c : prefix.toCharArray()) { if (searchStartNode.nodes[c - 'a'] == null) { return result; } searchStartNode = searchStartNode.nodes[c - 'a']; } dfs(searchStartNode, result); return result; } public void dfs(TrieSearch rootNode, List<String> outputforprefix) { if (outputforprefix.size() == 3) { return; } if (rootNode.word != null) { outputforprefix.add(rootNode.word); } for (int i = 0; i < 26; i++) { if (rootNode.nodes[i] != null) { dfs(rootNode.nodes[i], outputforprefix); } } } public TrieSearch callFillTrie(String[] products) { TrieSearch result = new TrieSearch(); for (String product : products) { insertIntoTrie(product, result); } return result; } public void insertIntoTrie(String product, TrieSearch trieSearchNode) { for (int i = 0; i < product.length(); i++) { char ch = product.charAt(i); int index = ch - 'a'; TrieSearch searchNode; if (trieSearchNode.nodes[index] == null) { searchNode = new TrieSearch(); trieSearchNode.nodes[index] = searchNode; } searchNode = trieSearchNode.nodes[index]; if (i == product.length() - 1) { searchNode.word = product; } trieSearchNode = searchNode; } } class TrieSearch { String word; TrieSearch nodes[] = new TrieSearch[26]; } }
@preetnandeshwar5331
@preetnandeshwar5331 8 ай бұрын
for 2nd solution eg. " )(* " expected ans - False as per soln - True i think second solution is not valid
@Omchaudhary07
@Omchaudhary07 6 ай бұрын
@preetnandeshwar5331 see when first character is ')' [closing bracket] then according to the condition minleft= max(0,minleft-1) so minleft=0 and maxleft=maxleft-1 so maxleft=-1 after that at last one condition is there if(maxleft<0) return false so this algorithm will give answer=false.
@zhunzargulhane6741
@zhunzargulhane6741 8 ай бұрын
What is this man, you dont even know how to explain the algorithm, you are just showing the code. Where is intuition, approach and nothing is explained clearly. Please improve yourself, you are wasting others time.
@JainShrayansh
@JainShrayansh 8 ай бұрын
Sorry, I am not a DSA expertise, this channel I have created for my DSA practice and maintaining my consistency. But I will try to add those details which you have mentioned. Thanks for the feedback
@aakashpawan1542
@aakashpawan1542 9 ай бұрын
Hi Shrayansh, I miss this series. I have decided to follow along with you for 100days. But unfortunately, There were no videos for the past 2 weeks now. What happened?
@JainShrayansh
@JainShrayansh 8 ай бұрын
Hi, sorry buddy, got involved in couple of office projects with hard timelines. I am practicing but video making is not getting possible, as creation/ uploading takes time too. I am solving 3 days in a week for now, But hope from December I will start uploading video too.
@subramanyamshankar1767
@subramanyamshankar1767 9 ай бұрын
Problem for food in Chennai is a joke.
@subramanyamshankar1767
@subramanyamshankar1767 9 ай бұрын
try to learn south Indian language when you come to south. don’t impose Hindi here.
@spinandexplore
@spinandexplore 8 ай бұрын
It's very hard to learn these noodles like language 😂
@subramanyamshankar1767
@subramanyamshankar1767 8 ай бұрын
@@spinandexplore then don't come here
@subramanyamshankar1767
@subramanyamshankar1767 8 ай бұрын
@@spinandexplore at least you can learn to speak..... Or communicate in English. Don't impose Hindi
@spinandexplore
@spinandexplore 8 ай бұрын
@@subramanyamshankar1767 Who is imposing Hindi here, if you guys can understand it then try to communicate and cooperate with us. No one wants to leave their native place but life creates such situations that we have to leave it.
@subramanyamshankar1767
@subramanyamshankar1767 8 ай бұрын
@@spinandexplore guys coming from North have no inclination to learn local language.... When we south Indian come to north, we learn Hindi.
@utsavchandra7220
@utsavchandra7220 9 ай бұрын
Millenia Business Park Phase - II Campus 3A 143, Dr. M.G.R Road, N Veeranam Salai, Kandhanchavadi, Perungudi, Chennai, Tamil Nadu 600096 Idhar office ho to kaha rehna sahi rehega aur kitna kharcha ho sakta hai for single living? For pg and 1bhk or 1RK flat? Btw, I have been searching for a good comprehensive vdo regarding this and your video is the proper one I need. So, thank you❣️
@NaveenKumar-ul5zz
@NaveenKumar-ul5zz 9 ай бұрын
Hi Shrayansh, Please post the question by Morning so that we can give it a try before coming to the solution video. Kindly consider.
@JainShrayansh
@JainShrayansh 9 ай бұрын
Yes, sorry generally i do this but i forgot to post today. Will do it from tomm
@NaveenKumar-ul5zz
@NaveenKumar-ul5zz 9 ай бұрын
@@JainShrayansh No issues Shrayansh! Apart from your office work, you are doing this and helping us a lot! Thanks a lot!
@JainShrayansh
@JainShrayansh 9 ай бұрын
Thanks buddy.
@spencer4648
@spencer4648 9 ай бұрын
Promo`SM
@Alan-xj5nc
@Alan-xj5nc 9 ай бұрын
2 nd question do check it out and suggest any optimizations #include <iostream> #include <bits/stdc++.h> using namespace std; int ans = INT_MIN; void f(int idx,vector<int> &arr,int cnt,vector<int> &dp); int main() { // Write C++ code here vector<int> arr = {34,23,1,2,42,12,2,4,1,3,4,7,7,8,8,9,9,12}; //output : 3 pairs to be deleted = 34,23 | 42,12 | 1,3 vector<int> dp(arr.size(),-1); for(int i=0;i<arr.size();i+=2){ f(i,arr,1,dp); } cout<<arr.size()/2 - ans; return 0; } void f(int idx,vector<int> &arr,int cnt,vector<int> &dp){ // cout<<"Running"<<endl; // int ans = INT_MIN; if(dp[idx]!=-1){ cnt = dp[idx]; return ; } if(idx>=arr.size()-2){ // cout<<"Running"<<endl; ans = max(ans,cnt); dp[idx] = ans; return ; } for(int k=idx+2;k<arr.size();k+=2){ // cout<<arr[k]<<endl; if(arr[k] == arr[idx+1]){ // cout<<"Runing"<<endl; f(k,arr,cnt+1,dp); } if(k>=arr.size()-2){ ans = max(ans,cnt); dp[idx] = ans; return ; } } }
@DurgaShiva7574
@DurgaShiva7574 9 ай бұрын
thanks for the question, dnf algo i think
@JainShrayansh
@JainShrayansh 9 ай бұрын
Yes
@DurgaShiva7574
@DurgaShiva7574 9 ай бұрын
Amazing questions, thanks for sharing, eagerly waiting for solutions from your side For the 2nd question, as we cannot re-order, as well as rotate, can we do it in O(n*n) complexity ?.. where for every given pair, we check for a matching pair in the index +1 of the given pair, and find the longest / max number of pairs doing the same in short, running two loops would do the work?.. please suggest
@JainShrayansh
@JainShrayansh 9 ай бұрын
Umm i don't think so two loops can help us with this question, , but pls try it out. I will also practise this
@santosh_bhat
@santosh_bhat 9 ай бұрын
We can't just do it with two loop since if there are multiple matching starting index (1,2) -> (2,4) (2,7) (2,8) -> .... We need to find the longest when we pick each of these separately and that is where recursion comes into picture.
@sdfg204
@sdfg204 5 ай бұрын
This mimics subsequence problems where we pick or not-pick based on condition, we just need the longest subsequence as it would have least deletions
@littlemini39
@littlemini39 9 ай бұрын
this was my solution with dynamic programming. I did not use any extra space as well: // Online C++ compiler to run C++ program online #include <iostream> # include<string> # include <vector> using namespace std; int returnAnswer(vector<int> arr) { int n = arr.size(); int value1 = 0; // dp[i-1] int value2 = 0; // dp[i-2] vector<int> dp(n,0); for(int i=0;i<n;i++){ int value3 =arr[i]; if(i-1>=0) { value3=max(value3,arr[i]+value1); value3=max(value3,stoi(to_string(arr[i-1])+to_string(arr[i]))+((i-2)>=0?value2:0)); } value2=value1; value1=value3; } return n==0? 0 : value1; } int main() { // Write C++ code here std::cout << "Hello world!"; int ans = returnAnswer({3,19,191,91,3}); cout<<ans; return 0; } I hope this helps :)
@JainShrayansh
@JainShrayansh 9 ай бұрын
Time complexity?
@manitank7001
@manitank7001 9 ай бұрын
Good explanation with deep details.. Thank you!!
@JainShrayansh
@JainShrayansh 9 ай бұрын
For the first question, i can add memorization to existing solution and it can reduce the time complexity to O(n)
@surajravishankar
@surajravishankar 9 ай бұрын
I wish they asked all this for the interview XD. I guarantee, with my luck, the day I sit for the interview they are going to ask me something along the lines of Graphs DP and all the super tough topics.
@JainShrayansh
@JainShrayansh 9 ай бұрын
:)
@ankit687kumar
@ankit687kumar 9 ай бұрын
can you please share the link where I can purchase the latest addition?
@JainShrayansh
@JainShrayansh 9 ай бұрын
Sure will check and update
@zaheerabass7955
@zaheerabass7955 9 ай бұрын
I was also solving using 2 pointers approach . Thanks for the 2nd approach class Solution { public void moveZeroes(int[] nums) { if(nums.length>1){ int firstPointer=0; int secondPointer=1; while(secondPointer<nums.length && firstPointer<nums.length){ if(nums[firstPointer]==0){ if(nums[secondPointer]!=0){ nums[firstPointer]=nums[secondPointer]; nums[secondPointer]=0; firstPointer++; } secondPointer++; }else{ if(nums[secondPointer]!=0){secondPointer++;} firstPointer++; } } } } }
@zaheerabass7955
@zaheerabass7955 9 ай бұрын
class Solution { public int[] sortByBits(int[] arr) { HashMap<Integer, ArrayList<Integer>> mapList = new HashMap<>(); for (int i : arr) { if(mapList.containsKey(getbitCount(i))) { ArrayList<Integer> list = mapList.get(getbitCount(i)); list.add(i); Collections.sort(list); mapList.put(getbitCount(i), list); }else { ArrayList<Integer> list = new ArrayList<>(); list.add(i); mapList.put(getbitCount(i), list); } } ArrayList<Integer> result =new ArrayList<>(); for(int i=0;i<=32;i++) { if(mapList.containsKey(i)) { result.addAll(mapList.get(i)); } } return result.stream().mapToInt(Integer::intValue).toArray(); } public String getBinary(int n) { StringBuilder s = new StringBuilder(); while(n>0) { s.append(n%2); n=n/2; } return s.reverse().toString(); } public int getbitCount(int n) { String s = getBinary(n); int count=0; for(int i=0;i<s.length();i++) { if(s.charAt(i)=='1') { count++; } } return count; } } brute force
@JainShrayansh
@JainShrayansh 9 ай бұрын
nice
@zaheerabass7955
@zaheerabass7955 9 ай бұрын
you forgot to share the LC link in description today
@JainShrayansh
@JainShrayansh 9 ай бұрын
:) sorry, actually I shared the Leetcode question no. In the title.so always forget to add
@kaiservonwien4826
@kaiservonwien4826 9 ай бұрын
Hello sir, can you please give me a tip, how to implement this code using class Scanner, so that I can input expression, and the console gives me an answer, thank you sir
@zaheerabass7955
@zaheerabass7955 9 ай бұрын
I am on notice period and I have 2 months in my hand till 3rd Jan. I have seriously followed your java series and I have learned a lot and built a lot of confidence in myself , Thank You So much for such amazing contents. I have one offer in my hand with 35% increment but that is with one service based company. I am trying my best and need to start your system design videos. Just want your input 2 months would be enough to crack a good prouct based company if i spend 6-7 hrs daily in preparation and practice?
@JainShrayansh
@JainShrayansh 9 ай бұрын
Ack, will add my answer in evening
@zaheerabass7955
@zaheerabass7955 9 ай бұрын
@@JainShrayansh Hi Shrayansh, If you get time can you answer ?
@JainShrayansh
@JainShrayansh 9 ай бұрын
hi, regarding your question 2 month is sufficient to clear product based company. i can see you can spend good amount of time per day for preparation, So definitely 2 months is a good time. But many things depends on how many companies interviews you are getting. What i mean is, even if your preparation in 2 months is top notch but not getting sufficient calls, then its a problem right. so while you are spending 6-7hrs for preparation daily, pls spend some good time on applying for the jobs (ask for referrals, apply directly, send mail to hr etc. ).
@zaheerabass7955
@zaheerabass7955 9 ай бұрын
@@JainShrayansh Sure Sure Shrayansh. I will really keep in my mind all the things which you have suggested. Thank You so much for taking your precious time to reply my question.
@zaheerabass7955
@zaheerabass7955 9 ай бұрын
Hi Shrayansh. It would be good if you add the LC link of the problem in the description. Thank You
@JainShrayansh
@JainShrayansh 9 ай бұрын
Sure
@DurgaShiva7574
@DurgaShiva7574 9 ай бұрын
one doubt, please guide, i am not getting why we arent doing the following : - while(I>=0){ nums1[k] = nums1[I] ; i--; k-- ;} whereas we are doing it for j / nums2 elements ??
@DurgaShiva7574
@DurgaShiva7574 9 ай бұрын
i think i got it, please confirm, this is because the resultant array is to be stored in nums1 itself, which is already present if I >=0
@JainShrayansh
@JainShrayansh 9 ай бұрын
Right
@DurgaShiva7574
@DurgaShiva7574 9 ай бұрын
starting from last instead of starting index is an simple, yet amazing and eye-opener approach, kudos
@JainShrayansh
@JainShrayansh 9 ай бұрын
Thanks