Love the way how you also provided what the expectation of the interviewer at that particular time was. Really helped in understanding how an interviewer thinks. Thank you :)
Hi Keerti, thanks for putting this type of content out. You actually looked like one of the interviews who are serious as well as 'nice' and helpful' at the same time giving space to the candidate to express themselves. The way you have edited the video giving references to what needs to be done when and the approach to be followed is also very helpful ! Thank you Keerti !
This is absolute gold. I urge you to please make an entire playlist with different incoming SDE's so we can see how different people handle the process . ❤️❤️
There is no gold in this. The first question was a failed attempt to display irrelevant graph and backtracking approach before finally doing a greedy solution which he couldn't even explain , the second question was just plain wrong, the solution was to use binary search. Gold my a**.
bro same , i didn't even not get clear understanding of 1st ques and solution he does , finally sigh of relief , that it is not possible to attempt best in interview everytime
video is to the point,the best thing i like,no unwanted discussion in starting and last ,they just start a video by solving questions and end up with conclusion.👍👍 keep it continue !
Great , specially awesome from Nishant, very few people will have the courage to give mock interviews publicly, that too after being selected at Microsoft, shows that he is ready to accept his mistakes and keep learning from whatever opportunity he gets. And interviewer was really helpful 😅
I am a second-year student. I kept trying it alongside and taking hints whenever you gave. I really enjoyed this. Please upload more such mock interviews.
Wow . This was an amazing mock interview. I myself really have come to know about lot things by watching the whole video which would not be possible if I would just had read some interview experience. Your videos are literally good . Keep uploading this kind of content 😊
His approach for the second question was wrong, he should have divided the number in 2 equal parts for even and (x-1/2, x+1/2) in case of odd. His approach will fail for A = [1, 100] k =1. he will give 99, but answer is 50
honestly, i was surprised with this approach. I initially came up with the optimised approach but then after following the video for first half, i was like, maybe this approach is better and the moment you guys came to the optimised version, i literally paused the video and gave a pat on my back :p Good content. Learnt a lot from this.
These videos are so informative and insightful. Just one thing after 2 months into leetcoding, whenever there is a term/relation to maximize the minimum or minimize the maximum, the first approach should be to solve using Binary Search! I guess it would even work in the second problem.
This was an amazing video, shows how things actually goes in a real DSA round. I think it will be helpful for those who are new and unaware of this. Also, will help as a guide to boost confidence before any actual DSA interview.
Wow this was definitely one of the best mock interviews I've seen so far. 😂 I was pausing just before Nishant bhai and was trying to answer the question given by mam and lol even I did the same mistake of not properly reading the 2nd point. 😅😂 Yes mam, actually she even gave the time to read the question and also explained it a bit also told us that we didn't read the second point I don't think some Interviewers will be this patient and supportive tho
Good one. this kind of interviews will give us path to focus more on problem solving skills. Thanks for sharing. I also follow Nishant channel so I also wanted to see how he performed here. 😅
Thanks for this video keerti. It would be grateful if u could upload this type of content frequently. I am also from NIT CALICUT and as your junior i am really proud of you
it was a fantastic interview given by nishant to u his concept clarity is outstanding and as an interviewer urs as well . i liked the way u r connecting with him in between the time when he was answering . superb guys .keep going keerti and nishant
An Optimized solution for the second question would be to use binary search. the range of possible answers would be [1 - max number in given array] . we can just apply the binary search on this range and for each mid which we encounter we will just check whether or not it is possible to get that mid as the max number. If it is possible to get the mid as max we will check in the left part of the array and store the mid as ans, and if it is not possible for us to get that mid as max in given array we will check in the right part. we will do it until low < high. If low >=high we will come out of the loop. I hope it does make sense 🙂🙂
This video was soo good ma'am. Me as a 1st year student of CS, i have an idea of how mock interview would be and how we can talk and prepare for it. More mock interview and more questions plz would love it
the approach for first program is very simple it is a greedy problem where you just need to catch the theif to your leftmost in range so that the distance between theif and police decreased and you can catch maximum thiefs.
He definitely didn't answer the first question properly... As it's a straight forward greedy problem and he is thinking of doing graph, backtracking and all. If this is a interview he will be definitely rejected!!!
how can u directly conclude its a greedy prob, unless u first brainstorm the solutions possible and understand the core of the problem. He was really good to do that.
@@harshavardhanranger yes you need to think for a while, but not 30 minutes to come up with the approach after so many hints... I am not opposing nishant bhai, ppl sometimes may stack with the problem, but just want to say it was not up to mark performance to clear interview if it was an actual interview...
@Satish Sutar I am aware of that. And I'm a third year student from a Teir 3 college and I'm trying my best to change the fact that product based companies overlook Tier 3 college students.
Awesome video, get to know about really good perspective of how to approach solution and communicate with interviewer. Please make more videos like this!
The first question was very simple, 2 iteration (forward and backward) would have done the task. The question would have been solved for not more than 20 mins.
That seems to be a greedy approach which won’t work in second case since if P at index 2 catches T at index 1 then P at index 3 won’t be able to catch T at index 0 since distance is larger than k=2, so I don’t think it will work.
Used the concept of Stack to solve this. Like I used a police stack to store the indices of Police and another stack for theif. I used this because the condition states that each police can only catch one theif which indicates popping both the indices from each stack because they are of no use later. So the time complexity would be O(n) and Space complexity is O(n).
We can solve the first question using sliding window technique by take the window size = k and checking the ith and kth position for T and P. If ith and kth index is T and P, increment the count and move the window to right.
A very simple solution is For each policemen, tabulate every element at k distance from him thus their positions are already known as index_of_police + or - k . And then for each of them , try marking the left thief first and then if left DNE, then mark the right one. Once a T is marked, don't touch him again.
Max thief count problem solution has been made a little complicated by Nishant as I solved it with simple nested for loops and one Boolean array which will set an index to true whenever a thief is caught and based upon that Boolean value of thief index I can move forward. Finally I can count the total true values and that is the total count of thieves caught.
One genuine thing was..it was not scripted. Most of the times in such playlists interviewer already know the soln and act first 10-15 min and then come to brute with 100% confidence ..This one was completely done by him at instant ! Nice work guys .
second question approach will fail for tc [ 8 , 12 ] and k = 2 According to his approach answer will be [ 8 , 8 , 4] -> [ 4 , 4 , 8 , 4 ] so it is 8 whereas answer will be 6 [8 ,12] -> [ 8 , 6 , 6] -> [4,4,6,6]
From my experience with micosoft. Don't think and find solutions yourself. Those interviewer wont accept your own solution. They want exactly what is on the internet. Spend time in look all the websites and Better memories them as they are in Internet. 90% percent you will succeed.
I think Nishant bhaiya's approach for the second question will fail for the testcases like 2,100 and k = 1. Here Max(A) = 100 , Max2(B) = 2 ; So , C = 100 - 2 = 98 ; after inserting in priority queue we get {98 , 2 , 2} in priority queue. Since we have already exhausted our k(k was 1), our max answer will be 98 , but ideally it should have been 50.(If we had simply divided it by 2).
First Question with O(n*2) brute force approach inputarr=["T","T","T","P","P","T","T","P","P","P","P","T","T","T"] temparr= [0 for i in range(len(inputarr))] k=1 k=k+1 count=0 print(temparr) for i in range(len(inputarr)): if inputarr[i]=="P": for j in range(len(inputarr)): if (inputarr[j]=="T") and (abs(j-i)
#Keerti Purswani thanks for letting us to have Idea about interview session and also to expand the horizon. a humble request to you to share your knowledge with us regarding learning d s algorithm and programming questions so that we can take start early Doing the great work keep it up 👍👍
My approach -: 1.take a police array and thief array and store their corresponding index. 2.iterate on police array and if absolute difference b/w each element
This is very informative . I have been practising dsa from a long but yet not sure if i am ready for interviews or not. But this video really help to realize where i stand now. Thank you di ❤️
one thing that i understood from this video is that , interviewer don't want a correct solution with optimized space and time complexity in the very first try ,what he/she actually want is the discussion of 40 to 60 minutes on the question. He want to analyse how the candidate handle the situation when he got stuck or how good is he in grasping the hints . Thankyou Keerti and nishant for this video . 0_0
Really good one, keep going..... You finally smiled at 32:04, till then you kind of giving a confused look :) ... I also can hear some background noise/feedback, it could be a fan sound or something.. not sure..
His approach won't wok for [7,17], K = 2 as per his ans, we will do [7,7,10] then [7,7,7,3] and it ends. But we can get [7, 6,6,5] then [3,4,6,6,5] and we will have 6 as ans
A real mock interview Di...!! You really scared at some moments 😅😅... Also di he already declared vector and you were asking in which language will you be coding...😁😁 I am going to follow you greatly for my internship prep and placement prep🤟... And di one more thing if you could answer..are two projects enough...to display in our resume...of a webapp??...it would be of great help if you could let me know🤟🤟
Why am I scared though 🤭🤭 He is the one interviewing 🤭 Han I know, I wasn't expecting him to code in C++, plus I just asked so that viewers can know 😅😅 Depends on the projects and the level of your contribution 😊
thank you so much for asking the interviewee to speak in Hindi, I really wanted to know the solution and not miss anything cause I am not good with Hindi.
the best and worst time complexity of Nishant approach is O(2*n) as each index is covered 2 times(One when creating Thief and Police array and then iterating over them) I have coded this problem with queue and its worst time complexity is 0(2*n) as each index is covered atmost 2 times.
Can you do some frequently asked leetcode or hackerrank questions and the approach to solve them, what data structures should one use and why. Also some problems do not have a straightforward time and space complexity, so how do we tackle those. And keep going this is absolutely great and very helpful.
Testcase for Question 2 : arr = [ 2 30 ] k=1 Accoding to Nishant Solution ans = 28 but according to me we can split 30 into 15.15 to get [ 2 15 15 ] ans will be 15
Personally I feel that if the interviewer is explaining the question, he would sometimes hint the solution or maybe an approach to solve which can be a boon for the session. Corrections are always appreciated.
I do think solution is over-engineered , its a sliding window problem and it can be solved in 0n in one pass. with 2 counters one for result and one from -k to +k to keep count of pending police or thief , updating counter is bit tricky thou you dont need those vectors For 2nd qus the split should be either a/2,a/2 or a-b, b Where num is list is 1 4 3 9 12 and K as 2 having solution with a-b be 9 and a/b will be 6
I was surprised when he told exponential complexity without thinking much about array iteration. Not expected such quick awnsers without thinking much. I think it can be max n*2k complexity in brute force.
i think first question can be solved using unordered_set data structure easily by putting the thives in the set which can be catched by any police means they are catchable thief. if size of set > total no. of police return total no. of police. otherwise return total no. of thief.
@5:34 in that how the ans is 3🙄? It might be again 2 According to me bcz 2st index police man can catch 0th index 'T' 3rd index police can catch 1st index 'T' And last index police man would not able to catch any 'T' So if I am wrong plz explain me
I am thinking the same😂😂 the ans is 2. Edit- after thinking some time, he is correct because the policeman in last position is able to cath thief in second last position because he is less than 2 position far from police i.e 1 postion and in question it listed the a policeman cannot catch a thief who is more than k unit i.e 2 unit
PYTHON SOLN FOR QUES 1: lis=[] n=int(input()) for i in range(n): lis.append(input()) k=int(input()) count=0 for i in range(len(lis)): if lis[i] == 'P': for j in range(len(lis)): if lis[j]=='T': if(k>=abs(i-j)): count+=1 lis[j] = 'c' break print(count)
The first question can be solved very easily.We have to just put the indexes of the thieves in a ordered set.Then we traverse the indexes of polices from left.For every police we try to get an uncaught thief at the max allowable distance and if thats not found it will try to get the nearest thief to the right of police and then remove the thief's index from the set and increasing the counter by 1.By this process we are assuring that the police who are in the right side of the current police may get chance to catch the thieves at minimum distance thus increasing the probability of catching more thieves.
Cann't this question be solved using sliding window and HashMap 1.Take a window of K+1 items and maintain number of police and thiefs. 2. Find min of these values and subract with count of both police and thief. 3. Slide the window by 1, (reduce the count of the item removed from window , if any left and add new item) Keep doing this till window reaches end. Correct me if this solution won't work .
Hi Ankit, If you notice, he is doing the same thing finally. Instead of saving two vectors like he did, you are using hashmap And he used 2 iterators (2 pointers) and you are calling it window technique. If you have watched my window sliding technique video, I have explained how window technique is same as 2 pointer technique. Hope I was able to explain 😊
I guess my approach to this would be a multispurce bfs, We xab assume an edge betwen i amd i+1th element and then store all policeman in a queue after that simply run a multisource bfs in such a fashion that each policeman would catch the theif which is at maximum possible distance to him and not caught by othrs
Successfully cracked my MS interview today. Feeling great. Work hard guys it is worth the effort
Ms from iit or somewhere abroad
@@whatis962 he said Microsoft not masters 🤦♂️
Can u plzz give some tips from where to start and end and when Application comes out for MS recruitment 🙏🏻🙏🏻
Hii..So they only ask coding logic or theory also in interviews....I am curretly in testing from 2 years and learning DSA
No one cares
This is the most realistic mock interview I have seen honestly. More like this is really helpful!!
Thank you so much Ratul. Means a lot. Hope you like rest of the videos as well 😇
Love the way how you also provided what the expectation of the interviewer at that particular time was. Really helped in understanding how an interviewer thinks. Thank you :)
Thanks! Hope you like rest of the videos as well 😇😇
Please do such more mock interviews.Thanks for doing such videos :)
For sure. I hope the videos help 😇😊
Yes mam please make more videos
Thanks for sharing the tips as an interviewee! Please make such content in the future Keerti!
For sure Shehzad. So glad you liked it 🙏😇
Hi Keerti, thanks for putting this type of content out. You actually looked like one of the interviews who are serious as well as 'nice' and helpful' at the same time giving space to the candidate to express themselves.
The way you have edited the video giving references to what needs to be done when and the approach to be followed is also very helpful !
Thank you Keerti !
I've never seen Nishant this serious, lol. Great job, you guys. Keep the good content flowing.
Productive one 💯
More mock interviews like this ...pls
At least we freshers will get an idea what will have to do and not to do😅
Yup. That's the purpose. Entire playlist will be there. Stay tuned! 😊😊
@@KeertiPurswani thankyou dii
@Satish Sutar thanks to YT and especially Jio 😂
@@KeertiPurswani Yes ✌️
can u bring hitesh choudhary and some foreign coder@@KeertiPurswani
This is absolute gold. I urge you to please make an entire playlist with different incoming SDE's so we can see how different people handle the process . ❤️❤️
For sure Dhruv. Stay tuned 😇
And please do share the videos with your friends 🙏
There is no gold in this. The first question was a failed attempt to display irrelevant graph and backtracking approach before finally doing a greedy solution which he couldn't even explain , the second question was just plain wrong, the solution was to use binary search. Gold my a**.
bro same , i didn't even not get clear understanding of 1st ques and solution he does , finally sigh of relief , that it is not possible to attempt best in interview everytime
video is to the point,the best thing i like,no unwanted discussion in starting and last ,they just start a video by solving questions and end up with conclusion.👍👍
keep it continue !
Thanks Rajdeep. Means a lot 😇😇
Great , specially awesome from Nishant, very few people will have the courage to give mock interviews publicly, that too after being selected at Microsoft, shows that he is ready to accept his mistakes and keep learning from whatever opportunity he gets.
And interviewer was really helpful 😅
😁❤️
Exactly. It takes a LOT of guts and he agreed in once and was a great sport. More power to him❤️
@@NishantChahar11 Bhai Yh questions ko itna logically reach krna leetcode se aa paega yaa cp bhi krni hi pdegi... Please answer
@@abhigyansharma9108 cp must ..... do on codeforce
@@niteshnareshnarwade321 not mandatory
I am a second-year student. I kept trying it alongside and taking hints whenever you gave. I really enjoyed this. Please upload more such mock interviews.
More power to you Ravisha. If you are already doing this in second year, I am sure you are gonna do just amazing in future. Keep going ❤️
@@KeertiPurswani Thank You♥️
@@KeertiPurswani 😁 BTW I am doing it in 1st year(Non- CS branch though)☹️
First time I have seen that much long video completely. Great Interview Keerti, Good job Nishant :)
Thank you ❤️
this is so amazing that you have embedded comments for us... Thanks for your time :)
So glad you liked it. Thank you ❤️😇
Wow . This was an amazing mock interview. I myself really have come to know about lot things by watching the whole video which would not be possible if I would just had read some interview experience. Your videos are literally good . Keep uploading this kind of content 😊
Thanks Rydham. So so glad you liked and learnt from it! 😇😇
Even I overlooked the 2nd test case . It changes the whole situation.
but if in 2nd test case k would be onw then a-b approach is wrong ig
Sliding window is a good approach for the first one. We can solve it in one pass
Why not BS?
His approach for the second question was wrong, he should have divided the number in 2 equal parts for even and (x-1/2, x+1/2) in case of odd.
His approach will fail for A = [1, 100] k =1.
he will give 99,
but answer is 50
@UCpm7NOlzwUeehNpbBY8GAcg ur logic fails for the case that I have provided above lol 😂
I noticed that too! Also the second question was too easy and such questions rarely come up in an interview
@@saksham2091 can you tell me the solution with priority queue?
I think it can be solved using binary search
Me:- Concentrating on the code and explanation
Also Me:- Bhai Thief ki spelling galat h......
bro me to😂😂
honestly, i was surprised with this approach. I initially came up with the optimised approach but then after following the video for first half, i was like, maybe this approach is better and the moment you guys came to the optimised version, i literally paused the video and gave a pat on my back :p Good content. Learnt a lot from this.
These videos are so informative and insightful. Just one thing after 2 months into leetcoding, whenever there is a term/relation to maximize the minimum or minimize the maximum, the first approach should be to solve using Binary Search! I guess it would even work in the second problem.
This was an amazing video, shows how things actually goes in a real DSA round. I think it will be helpful for those who are new and unaware of this. Also, will help as a guide to boost confidence before any actual DSA interview.
Thanks Gaurav. That's exactly what I was hoping for. Many videos coming up soon! 🙂🙂
Wow this was definitely one of the best mock interviews I've seen so far. 😂 I was pausing just before Nishant bhai and was trying to answer the question given by mam and lol even I did the same mistake of not properly reading the 2nd point. 😅😂
Yes mam, actually she even gave the time to read the question and also explained it a bit also told us that we didn't read the second point I don't think some Interviewers will be this patient and supportive tho
Good one. this kind of interviews will give us path to focus more on problem solving skills.
Thanks for sharing.
I also follow Nishant channel so I also wanted to see how he performed here. 😅
This is Amazing!
Taking more mock interview for helping people.
For sure. Thank you! 🙏😇
Thanks for this video keerti. It would be grateful if u could upload this type of content frequently. I am also from NIT CALICUT and as your junior i am really proud of you
Mam it is the one of the best interview with tips , thanks mam ,,it taught me a lot that i could not able to learn in 4yrs of my college.
Thanks Aman 😅😅🙏🙏
This was great, I was coming up with the solution myself, and was applying my approach on docs.. please do more of these. :)
That's exactly how you are supposed to watch these videos. More power to you ❤️
Hope you are liking rest of the videos as well 😇😇
it was a fantastic interview given by nishant to u his concept clarity is outstanding and as an interviewer urs as well . i liked the way u r connecting with him in between the time when he was answering . superb guys .keep going keerti and nishant
An Optimized solution for the second question would be to use binary search.
the range of possible answers would be [1 - max number in given array] .
we can just apply the binary search on this range and for each mid which we encounter we will just check whether or not it is possible to get that mid as the max number. If it is possible to get the mid as max we will check in the left part of the array and store the mid as ans, and if it is not possible for us to get that mid as max in given array we will check in the right part. we will do it until low < high. If low >=high we will come out of the loop.
I hope it does make sense 🙂🙂
best solution
Solved both in 20 mins 😁thankyou
This video was soo good ma'am. Me as a 1st year student of CS, i have an idea of how mock interview would be and how we can talk and prepare for it. More mock interview and more questions plz would love it
Kindly organise such interveiw often so we can get an idea
For sure shivam 😊😇
I don't know why I am getting nervous while reading the questions 😄
Thank you for giving us Idea what to do and not to do ❤️
Happens with everyone Shubham! Hoping the videos help 😇🙏
@@KeertiPurswani definitely it help ma'am for student like me who just get admission in college 😊
the approach for first program is very simple it is a greedy problem where you just need to catch the theif to your leftmost in range
so that the distance between theif and police decreased and you can catch maximum thiefs.
Or check left and right both?
He definitely didn't answer the first question properly... As it's a straight forward greedy problem and he is thinking of doing graph, backtracking and all. If this is a interview he will be definitely rejected!!!
yes it is greedy bro i also think ... simple maniplutaion with index
how can u directly conclude its a greedy prob, unless u first brainstorm the solutions possible and understand the core of the problem. He was really good to do that.
@@harshavardhanranger yes you need to think for a while, but not 30 minutes to come up with the approach after so many hints... I am not opposing nishant bhai, ppl sometimes may stack with the problem, but just want to say it was not up to mark performance to clear interview if it was an actual interview...
This was amazing!
Could you have students from TIER 3 COLLEGES who have cracked product based companies or FAANG . That would be great!
Sure, noted 😊
@Satish Sutar I am aware of that. And I'm a third year student from a Teir 3 college and I'm trying my best to change the fact that product based companies overlook Tier 3 college students.
Pahli baar hasi udi hai chahar bhai ki🫡🫡
Awesome video, get to know about really good perspective of how to approach solution and communicate with interviewer.
Please make more videos like this!
So glad you liked it Ankita. Thank you❤️🙏😇
The first question was very simple, 2 iteration (forward and backward) would have done the task. The question would have been solved for not more than 20 mins.
That seems to be a greedy approach which won’t work in second case since if P at index 2 catches T at index 1 then P at index 3 won’t be able to catch T at index 0 since distance is larger than k=2, so I don’t think it will work.
@@nikunjkhakhkhar1030 why would P at index 3 need to catch T at index 0.. T at index 0 will be taken care bt P at index 2, for K=2
Used the concept of Stack to solve this. Like I used a police stack to store the indices of Police and another stack for theif. I used this because the condition states that each police can only catch one theif which indicates popping both the indices from each stack because they are of no use later. So the time complexity would be O(n) and Space complexity is O(n).
We can solve the first question using sliding window technique by take the window size = k and checking the ith and kth position for T and P. If ith and kth index is T and P, increment the count and move the window to right.
Yes...
Thank you, ma'am, for those tips you flash in between also help us greatly as to how the interviewer might be thinking. Very helpful, thank you!
Hi , I came across the video after watching the striver mock interview . Worth it .
subscribed :)
thanks for making this type of video.
came from nishant bhaiya's channel.
Welcome to the channel. Hope you like rest of the videos as well. I will keep creating 🙏😇
@@KeertiPurswani yaa i had watched rest of the videos on your channel 😇
Brute force will be O(n*k) for each policeman check from kth distance at left until there is thief.
Optimal O(n) use queue for thieves.
thank you for making this video it is very helpful for my interview
Awesome video.Itll be very useful for us if you can make more mock interviews especially for Amazon
Yup. Hoping the videos will help 😇😇
A very simple solution is For each policemen, tabulate every element at k distance from him thus their positions are already known as index_of_police + or - k . And then for each of them , try marking the left thief first and then if left DNE, then mark the right one. Once a T is marked, don't touch him again.
Max thief count problem solution has been made a little complicated by Nishant as I solved it with simple nested for loops and one Boolean array which will set an index to true whenever a thief is caught and based upon that Boolean value of thief index I can move forward.
Finally I can count the total true values and that is the total count of thieves caught.
Simply use binary search concept. That's what was required here
One genuine thing was..it was not scripted. Most of the times in such playlists interviewer already know the soln and act first 10-15 min and then come to brute with 100% confidence ..This one was completely done by him at instant ! Nice work guys .
second question approach will fail for tc
[ 8 , 12 ] and k = 2
According to his approach answer will be [ 8 , 8 , 4] -> [ 4 , 4 , 8 , 4 ] so it is 8
whereas answer will be 6
[8 ,12] -> [ 8 , 6 , 6] -> [4,4,6,6]
From my experience with micosoft. Don't think and find solutions yourself. Those interviewer wont accept your own solution. They want exactly what is on the internet. Spend time in look all the websites and Better memories them as they are in Internet. 90% percent you will succeed.
Ye chaprii mere college ka h isko kuch nhi aata🤣
Was able to code first question in mere 2 minutes. Extremey elated. yesssssss!!
Kaise hoga
I think Nishant bhaiya's approach for the second question will fail for the testcases like 2,100 and k = 1. Here Max(A) = 100 , Max2(B) = 2 ; So , C = 100 - 2 = 98 ; after inserting in priority queue we get {98 , 2 , 2} in priority queue. Since we have already exhausted our k(k was 1), our max answer will be 98 , but ideally it should have been 50.(If we had simply divided it by 2).
0:06 now he got 200k+ subs..!! gone a long way
First Question with O(n*2) brute force approach
inputarr=["T","T","T","P","P","T","T","P","P","P","P","T","T","T"]
temparr= [0 for i in range(len(inputarr))]
k=1
k=k+1
count=0
print(temparr)
for i in range(len(inputarr)):
if inputarr[i]=="P":
for j in range(len(inputarr)):
if (inputarr[j]=="T") and (abs(j-i)
Gud work! Please do more mock interview like these...Thank you!
One more is up today. Hope you like it ❤️😇
The second answer would fail for 18,17 and k=2.
yes. even with 7, 17 and k=1
@@namantewari7586 yeah dude i was thinking same that will work only if k is greater than 2 ig
#Keerti Purswani
thanks for letting us to have Idea about interview session and also to expand the horizon.
a humble request to you to share your knowledge with us regarding learning d s algorithm and programming questions so that we can take start early
Doing the great work keep it up 👍👍
My approach -:
1.take a police array and thief array and store their corresponding index.
2.iterate on police array and if absolute difference b/w each element
This is very informative . I have been practising dsa from a long but yet not sure if i am ready for interviews or not. But this video really help to realize where i stand now. Thank you di ❤️
So glad it helped Mahak. Thank you 🙏❤️
All the best for your interviews 😊😊
so are you ready
one thing that i understood from this video is that , interviewer don't want a correct solution with optimized space and time complexity in the very first try ,what he/she actually want is the discussion of 40 to 60 minutes on the question. He want to analyse how the candidate handle the situation when he got stuck or how good is he in grasping the hints .
Thankyou Keerti and nishant for this video . 0_0
Zomato वाले बन्दे की तरह smile किया था starting में ...😊
Seeing this ,I learnt a lot ,thank you very much Mam . Please upload more these types of mock interviews
Explaining the question looks great. coz it gives better understanding and can get more hints😂
It is very good. I learn a lot about do's and don't in interview. I am looking for more such mock interview. Thank u so much.
Thanks Ranvijay. More coming up! 😊😇
The second was Based on Binary Search I guess It was like allocate Minimum no of Pages
0:01 I thought you were cleaning your screen
i am your new subscriber .
it would be helpful if could upload more Mock coding interviews.
Welcome to my channel Vaibhav. Hope you like rest of the videos as well. More mock interviews coming up 😊😇
This was the best learning experience so far. Please make more such videos, it really makes me feel as if I am giving the real interview.
For sure Vineeth. Glad you liked the video 😇
Really good one, keep going..... You finally smiled at 32:04, till then you kind of giving a confused look :) ... I also can hear some background noise/feedback, it could be a fan sound or something.. not sure..
His approach won't wok for [7,17], K = 2 as per his ans, we will do [7,7,10] then [7,7,7,3] and it ends. But we can get [7, 6,6,5] then [3,4,6,6,5] and we will have 6 as ans
We can divide a number into 2 numbers ... You did [7,17] = [7,6,6,5]
It will take 2 steps to do that.
A real mock interview Di...!! You really scared at some moments 😅😅...
Also di he already declared vector and you were asking in which language will you be coding...😁😁
I am going to follow you greatly for my internship prep and placement prep🤟...
And di one more thing if you could answer..are two projects enough...to display in our resume...of a webapp??...it would be of great help if you could let me know🤟🤟
Why am I scared though 🤭🤭 He is the one interviewing 🤭
Han I know, I wasn't expecting him to code in C++, plus I just asked so that viewers can know 😅😅
Depends on the projects and the level of your contribution 😊
thank you so much for asking the interviewee to speak in Hindi, I really wanted to know the solution and not miss anything cause I am not good with Hindi.
I understand. This channel is for you as well 😊
@@KeertiPurswani thanks :)
the best and worst time complexity of Nishant approach is O(2*n) as each index is covered 2 times(One when creating Thief and Police array and then iterating over them)
I have coded this problem with queue and its worst time complexity is 0(2*n) as each index is covered atmost 2 times.
Can you do some frequently asked leetcode or hackerrank questions and the approach to solve them, what data structures should one use and why. Also some problems do not have a straightforward time and space complexity, so how do we tackle those. And keep going this is absolutely great and very helpful.
Testcase for Question 2 :
arr = [ 2 30 ] k=1
Accoding to Nishant Solution ans = 28
but according to me
we can split 30 into 15.15 to get [ 2 15 15 ] ans will be 15
more mocks like this would be great!!
thank you ma'am for this video.
Please make more videos like this.
Very helpful session done by you and Nishant Bhaiya.Thank you
Personally I feel that if the interviewer is explaining the question, he would sometimes hint the solution or maybe an approach to solve which can be a boon for the session. Corrections are always appreciated.
I'm so amazed THank you so much
Mam please Do more mock videos like this . Thank you mam for making such videos.
Thanks Intuit Vali didi ...u r awesome💕
This is new. Pehli baar suna "Intuit vali didi" 🤭🤭😂😂
@@KeertiPurswani ap ho na hmare intuit vali didi :)
I do think solution is over-engineered ,
its a sliding window problem and it can be solved in 0n in one pass. with 2 counters one for result and one from -k to
+k to keep count of pending police or thief , updating counter is bit tricky thou
you dont need those vectors
For 2nd qus the split should be either a/2,a/2 or a-b, b
Where num is list is 1 4 3 9 12 and K as 2 having solution with a-b be 9
and a/b will be 6
The solution to the first problem will fail for test case 1. The if condition in while loop needs to test both positive k and negative k.
It is really very helpful.
Please keep making such type of videos keerti❤️
So glad toy liked it Shubham. More videos coming up 😇😇🙏
I feel the second question is solved wrongly. It will fail for a simple TC as arr = {2, 17} and k = 2.
I was surprised when he told exponential complexity without thinking much about array iteration. Not expected such quick awnsers without thinking much. I think it can be max n*2k complexity in brute force.
i think first question can be solved using unordered_set data structure easily by putting the thives in the set which can be catched by any police means they are catchable thief. if size of set > total no. of police return total no. of police. otherwise return total no. of thief.
O(nlogn)will be time complexity for your soultion
@5:34 in that how the ans is 3🙄?
It might be again 2
According to me bcz 2st index police man can catch 0th index 'T'
3rd index police can catch 1st index 'T'
And last index police man would not able to catch any 'T'
So if I am wrong plz explain me
I am thinking the same😂😂 the ans is 2.
Edit- after thinking some time, he is correct because the policeman in last position is able to cath thief in second last position because he is less than 2 position far from police i.e 1 postion and in question it listed the a policeman cannot catch a thief who is more than k unit i.e 2 unit
@@abhishekbaurai8780 thanks bro 😁😁😁 now I got it......
Actually maine dubar socha nhi ess bare me 😂
PYTHON SOLN FOR QUES 1:
lis=[]
n=int(input())
for i in range(n):
lis.append(input())
k=int(input())
count=0
for i in range(len(lis)):
if lis[i] == 'P':
for j in range(len(lis)):
if lis[j]=='T':
if(k>=abs(i-j)):
count+=1
lis[j] = 'c'
break
print(count)
Thank you so much such a helpful vedio and inspiring
Tysm kerti di👍🎉
The first question can be solved very easily.We have to just put the indexes of the thieves in a ordered set.Then we traverse the indexes of polices from left.For every police we try to get an uncaught thief at the max allowable distance and if thats not found it will try to get the nearest thief to the right of police and then remove the thief's index from the set and increasing the counter by 1.By this process we are assuring that the police who are in the right side of the current police may get chance to catch the thieves at minimum distance thus increasing the probability of catching more thieves.
That would be brute force O(nk)
@@aj9706 not exactly if we use an ordered set that will be n log k
Cann't this question be solved using sliding window and HashMap
1.Take a window of K+1 items and maintain number of police and thiefs.
2. Find min of these values and subract with count of both police and thief.
3. Slide the window by 1, (reduce the count of the item removed from window , if any left and add new item)
Keep doing this till window reaches end.
Correct me if this solution won't work .
Hi Ankit,
If you notice, he is doing the same thing finally. Instead of saving two vectors like he did, you are using hashmap
And he used 2 iterators (2 pointers) and you are calling it window technique. If you have watched my window sliding technique video, I have explained how window technique is same as 2 pointer technique. Hope I was able to explain 😊
Understood. Thank you for replying. 🙂
Nice.....Do more videos of this kind.....
very good content, i did solved first question but got stuck at 2nd, there are 3 years of my btech left so maybe i will improve.
I guess my approach to this would be a multispurce bfs, We xab assume an edge betwen i amd i+1th element and then store all policeman in a queue after that simply run a multisource bfs in such a fashion that each policeman would catch the theif which is at maximum possible distance to him and not caught by othrs