Today, many KZbinrs are only focused on sharing more materials, without considering how companies are asking questions or how freshers can really face interviews. Great work by Striver and GFG for providing practical advice on these topics.
@avtarchandra24072 жыл бұрын
Here i can see Arjit is struggling to get approach in the very start that clearly shows a real feel to interview ...a nice video to learn a lot from thank you @striver for such gem content ❤️❤️.....I want to know how you choose interviewee?
@lokanathpatasahani8972 жыл бұрын
We need more such type of mock interviews
@momidimidhilesh8292 жыл бұрын
First thought comes to mind after seeing this question is Coin Change. 1. Find first 3 primes(precompute primes if given lot of queries) 2. BFS to get minimum primes
@rajrajesh16698 ай бұрын
BFS or DFS ?! Coin Change problem can be solved by DFS.
@hello_everybody-sm6xi7 ай бұрын
@@rajrajesh1669 BFS we can use
@DEBJYOTIRAY-hl6ip7 ай бұрын
why do we need bfs? just apply the coin change problem and the coins available are all the prime numbers upto the given target limit
@rachitaa._Ай бұрын
This is so insightful for freshers who have never given an interview , have so many questions and they are getting answered here . The anxiety of giving an interview and everything else how it happens goes the process.
@rohitraj58322 жыл бұрын
The very first intuition i got after seeing the question was that , first i will prepare M primes in some array/vector. Then i can relate this qn. to unbounded knapsack problem (coin change problem where I've to find minimum number of denominations to make Target price). Or target sum problem to find minimum number of elements to make target . Striver Dp series helped me alot to think out of the box also ❤️❤️. thanks @striver
@sudityagupta91932 жыл бұрын
I thought the same approach bro
@heisenberg3488 Жыл бұрын
in same I thought
@yashaneypvt Жыл бұрын
Same
@pulkitjain5159 Жыл бұрын
ya the same thing i realted it to , and same with help of striver's dp series . but don't you think the constraints are too tight.
@Groot1306 Жыл бұрын
same thought process bro....
@arkamukherjee3962 Жыл бұрын
Brute force of this solution that strike in my mind is making a vector to store all the m primes and after that use unbounded knapsack to find minimun number of prime to make n
@chandannikhil85262 жыл бұрын
For brute force approach we can tell that storing ist M prime no in array then simple do combination sum where duplicacy allowed that is we can use same element again T.c : exponential S.c O(M)
@maremandasreekrishna85792 жыл бұрын
I am thinking of same approach when i first saw problem
@jaysingh14572 жыл бұрын
I also thought of the same approach
@sudeepbattu55252 жыл бұрын
Minimum coin change with repetions allowed and the array filled with first M primes
@AnujMathsShortcut Жыл бұрын
Mixture of Sieve and Knapsack.
@aayushverma41392 жыл бұрын
Sieve of eratosthenes + dp on subsequences
@reamerx6 ай бұрын
Sieve is enough without dp Generating prime number till 10 Will make a cnt aswell Then return the cnt directly
@debapratimshyam1492 жыл бұрын
I think what he was talking at the end about functions is "Pure Functions". Changing a global variable from within a function is a "Side effect" and it's a bad practice to do that unless absolutely necessary. Pure functions should not have any side effects and given a set of input you can be rest assured that the output will always be the same no matter how many times the function is called.
@vijaykumarbille772710 ай бұрын
Clearly understood 💯...How companies approach a fresher
@AyushGupta-kb9iv2 жыл бұрын
minimum coin required + seive
@krishangaur887717 күн бұрын
The first approach that came to my mind is to create a vector/array of size M, which stores the first M prime numbers up to the given number N. After this, we apply the Combination Sum.
@Noob_Coder12346 ай бұрын
after seeing the second test case it was pretty simple to undeerstand that there are so many ways so when many ways comes it comes to recursion and then we can move for dp also
@noedie49732 жыл бұрын
thanks! lot to learn here even if you get the question by yourself.
@suvigyabasnotra73782 жыл бұрын
Show us an interview as well where the candidate barely knows anything...!
@suvigyabasnotra73782 жыл бұрын
But still clears it...!
@takeUforward2 жыл бұрын
Scripted karne bol rahe ho 😂
@suvigyabasnotra73782 жыл бұрын
@@takeUforward Just kisi random CS student ka interview lene ko... jahan usey kuchh na aata ho... which would reflect the reality for most students. 😂
@madetolaugh34762 жыл бұрын
@@takeUforward bahi...video aayi nhi yrrr...subah se wait kar rahe hain
@tonystonks44892 жыл бұрын
@@suvigyabasnotra7378 realistically someone with no knowledge won't clear the OA of MAANG level companies and won't get a chance of interview.
@anushk_iitg8 ай бұрын
7:33 LOL, sieve of.....what !!? 😂
@pravallika_0915 күн бұрын
deriving all prime numbers upto N and storing in list or array and their are 2 cases two cases either i pick number if i picked M-1 else same M in not picked case and here N is target I think something similar coinchange
@rachitaa._Ай бұрын
loved this session so much
@idontKNOW-pb9hs2 жыл бұрын
So inspiring men striver you are really great!!!
@swapyswap5887 Жыл бұрын
binary search lower bound 1st que
@captainmcduckyYT2 жыл бұрын
If they're asking this level of questions for an OA. Then I won't even make it to the interviews lol.
@venky3011111 ай бұрын
Million dollar DSA problem - Given k, X and a stream of numbers , determine the average of the last k numbers , excluding the largest X numbers
@krishmakhija83337 ай бұрын
i think quetion can be easily solved using lower bound concept. in nlogn complexity.
@anujbajpai57915 ай бұрын
I think most people puzzled with the solution as it was iterative approach, doing the memoization way would have been easy to absorb
@key2success467Ай бұрын
Thank you man❤
@manojkr7554 Жыл бұрын
25:00
@honeyyadav9767 Жыл бұрын
What about we use bfs algorithm? Like simply store first m primes in a queue and then just simply keep iterating until you get the value
@varunmanchanda39722 жыл бұрын
Coin Change variation where coins are M, and target sum is N, and how come 5+3+2 is 11 ?
@HariKrishnan-ff4hf2 жыл бұрын
5+3+3=11 . We can take infinite supplies.
@objectofmathematics2 жыл бұрын
@striver@GeeksforGeeks if N
@kasiruyamagata77162 жыл бұрын
No the qn is minimum numbers of prime numbers less than m is required to sum up to n This qn is quite similar to coin change
@aamirhannan890 Жыл бұрын
@@kasiruyamagata7716yeah! I could relate this to the coin change with infinite supply!
@anirbanghosh96112 жыл бұрын
Definitely top notch content
@aditkaushal93977 ай бұрын
sieve of eratosthenes + dp on subsequences(coin change problem modified)
@HamzaSayyed4046 ай бұрын
Any similar question to practice ? (Dp + sieves combination)
@prantobala85057 ай бұрын
Can anyone give a test case where gready fail?
@niteshsaxena034 ай бұрын
do all companies ask CP based questions?....as sieve is a CP topic
@sonakshibajpai64457 ай бұрын
very useful !
@himanshukandwal87102 жыл бұрын
why he just started with tabulation i.e most optimal approach rather giving bruteforce approach first, at 22:02
@takeUforward2 жыл бұрын
There is no generic rule to problems which are not standard ones.
@codingaspirant94462 жыл бұрын
Loved it Sir ❤❤❤
@vishwaratnasharma21402 жыл бұрын
Is it possible .. to get the the list or all M primes and thn apply Target sum and count minimum counts
@abhinavraj13387 ай бұрын
Yess
@raj006 Жыл бұрын
At 7:34 which thing he mentioned he can use to find first n primes?
@sakshamShukla_ Жыл бұрын
sieve of eratosthenes
@VishnuKumar-fo2rl Жыл бұрын
yaar itna time kaha dete hain wo log bas 5-10 min and btw ye question 10 min ka hai baki aap jaisa interviewer milega to badhiya kismat
@noobchess25167 ай бұрын
can we do sieve and binary search on search to get lower bound till n=0 if anyway in mid way lower bound out of sieve return -1
@krishmakhija83337 ай бұрын
ya but if by subtracting you go 1 then at that time add one instance of last lower bound number and do ans--
@we2riruruirirfj Жыл бұрын
similar to combination sum
@sastapasta86926 ай бұрын
Can You Add These Questions To GFG, I Have Prepared Solution For Few But Can't Find An Online Judge To Check Them I Don't Wanna See The Solution Mentioned In The Video As I Wanna Approach To Correct Answer Myself. Please Add Them
@itz_ritzu8 ай бұрын
What if we find first M primes using a Sieve, and then use a recursion on that list with a constraint of M[prime] < N ? that would just take around O(n) time asymptotically? (I'm not sure Im solving it as I see the question 1st time so I'll update later). Lets take an example: Say I take N=10 and M=1. So my M list is: M[]={2} //since 1st prime is M Now of course here 10%2 is 0 so it works (we can do 10/2 to see how many 2's we need) For the next problem: N=11 M=3 So my M list is: M[]={2,3,5} //3 primes Here, we can see M[3] < N //and M is strictly increasing list so we don't need to check more We see 11%5 !=0 We store 5 in a list say K. So we subtract 5 from 11 i.e. 6 and call this same function on 6 with M[]={2,3}, and concatenate the output on K[]. so what I mean is we get 5 first, then we send 6, so we have M[]={2,3} so we check 6%3 and its 0 so we do 6/3 to see how many 3's we need. So finally we get {5,3,3} is that correct? lemme check P.S. the answer is 5,3,2 in the doc and it seems my disappointment is immeasurable, and my day is ruined.
@kushalswarup26622 жыл бұрын
7:35 whaaaat
@yeshwanthvatti2200 Жыл бұрын
Sieve of erathosthenes.
@as_if6 ай бұрын
Last time I checked this video, I was scared. This time, I'm still scared. Phak, I have made no improvement
@higgsboson676 ай бұрын
After how long did you rewatch ?
@sudhiranjangupta75172 жыл бұрын
Unbound Knapsack ... Dekhte hi bola 😂😂😂
@swatantrapatel76082 жыл бұрын
❤️❤️
@anirbanc882 жыл бұрын
i don't get the first question, what does it mean? help?
@kasiruyamagata77162 жыл бұрын
This qn is similar to coin change
@mandavasairaghavendradines6582 Жыл бұрын
2+3+5 is 10 right. Why he told its 11?
@atharvak15038 ай бұрын
5, 3, 3
@godFather-123-b8g12 күн бұрын
he should hv wrote rec code first instead of directly writing tabulation code
@shivamsolanki91537 ай бұрын
I also solver the question but take an hour 🙁
@KurumiddeKezia5 ай бұрын
hello
@SanjanaSingh-mc6re2 жыл бұрын
Why can't we use greedy approach here? Like for N=11 and M=3, I could have started from the biggest prime no. that's gonna be 5 and subtract that value from N and update value of N until I don't get value of N less than the current prime no or value of N==current prime no+1. In that case, I will move towards the smaller prime no and try to do the same thing with that. If N!=0 then we can't make N with the help of first M prime no.
@shardendushekharchaubey55822 жыл бұрын
You'll also have to handle an edge case like n=4, m=2 Or n=6 m=3
@shardendushekharchaubey55822 жыл бұрын
Here greedy can give -1 because from 4, it'll subtract 3, then 1 remains which is not possible.... So we'll have to add a condition that after the subtraction, the remaining no. Should not be 1
@tanishapandey51566 ай бұрын
import java.util.*; class HelloWorld { static boolean a[]; static ArrayList b=new ArrayList(); public static void solve(int n,int m) { Arrays.fill(a,true); int o=0; for(int i=2;ib.get(i)) { ans+=(n/b.get(i)-1); n=n%b.get(i)+b.get(i); } } System.out.println(ans); } } I checked for these edge cases and it is working can you let me know any case in which it is failing
@kartiknagrale14795 ай бұрын
@@shardendushekharchaubey5582 after subtracting if its 0 we got answer, but if we get 1 then don't take it, move towards smaller prime.
@prabhattiwari00710 ай бұрын
Striver se sikh ke striver ko interview dene ka maza hi alag h😂
@vishnuvarunthorthi8 ай бұрын
test
@namansharma7531 Жыл бұрын
Step1: Make an array with first M prime numbers Step2: Use unbounded knapsack code: import java.util.*; class Solution { public static int minPrimes(int N, int M) { int[] arr = findPrimes(M); int ans = unbounded_Knapsack(arr, N); return ans; } public static int unbounded_Knapsack(int[] nums, int N) { int len = nums.length; int[][] t = new int[len + 1][N + 1]; for (int i = 0; i
@ArpitGJoshi6 ай бұрын
agar esa hota hai to meri job toh lagne se rahi😰😰😭
@mukulbansal82695 ай бұрын
kabhi kisi ko amazon ko amahzin bolte suna hai
@frickofunky20082 жыл бұрын
his voice was shaking
@shamsulhaque552 жыл бұрын
All fake and bogus
@Sushank7772 жыл бұрын
Are you good at problem solving?
@shamsulhaque552 жыл бұрын
@@Sushank777 No one is !
@Sushank7772 жыл бұрын
@@shamsulhaque55 stfu... those who work hard to improve problem solving skills are good at it... So, go first improve yourself it's better than criticising someone who is 1000X better than you. Btw what's your codechef or codeforces profile?
@dakshsinghrathore95842 жыл бұрын
🤣
@ojasdighe9912 жыл бұрын
@@shamsulhaque55 i am
@bharathraj93312 жыл бұрын
How can I get a chance to give a live mock with striver?? @striver @take U forward