Тёмный

Mock Coding Interview with Googler, YouTuber  

Keerti Purswani
Подписаться 145 тыс.
Просмотров 50 тыс.
50% 1

Опубликовано:

 

28 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 93   
@hamsalekhavenkatesh3440
@hamsalekhavenkatesh3440 2 года назад
I have another idea- instead of dp...we can maintain 2 sums (prefixSum left , prefixSum right)..find the mid/cut point on where to Split - > (i), such that u want a running min (rightPrefix[i] < leftPrefix[i-1]) for all i. Then depending on the sign of rightPrefix[i] -leftPrefix[i-1], u can determine whether to discard left array or right array . To elaborate - currentDist = rigthPrefix[i] - leftPrefix[i-1]; if currentDist > 0 { //prefixRight is bigger, so consider prefixleft cutStart = 0; cutEnd = i; } else { //prefix left is bigger cutStart = i + 1; curEnd = length; } else { // this is where things become little tricky, if we know the integers are going to be always +ve, then we can greedily choose the side that has max number of elements. This is guaranteed to give max score. } Total time is O(N2)
@NitishKumar-o1y1v
@NitishKumar-o1y1v 4 дня назад
Am I the only one who replays her videos over and over just for that 'Hi guys!' and that big hand wave?
@satwikkashyap6753
@satwikkashyap6753 2 года назад
Stone Game - V (Leetcode)
@chaitanyavarma8093
@chaitanyavarma8093 Год назад
Code for anyone wondering, Nlog(N) import bisect arr = [6,4,4,5,7,8,9] n = len(arr) pre = [0]*(n+1) for i in range(1,n+1): pre[i]+=pre[i-1]+arr[i-1] i ,j = 1, len(pre)-1 res = 0 while iop1: k-=1 left ,right = pre[k] - pre[i-1], pre[j] - pre[k] if left>right: i = k+1 res+=right else: j=k res+=left print(res)
@priyanshagarwal2095
@priyanshagarwal2095 2 года назад
I think we can further optimize using prefix sum Because *** there are only three scenerio where can end up to optimal answer Suppose arr[]={ a , b , c , d} Every time we divide array such that it closest to the equal first when we divide the array perfectly (where score of both is equal) Recur both the arrays Else We check with left part smaller than totSum/2 and check right part smaller than totSum/2 Max of both will be the answer
@KunalSingh-yk7jw
@KunalSingh-yk7jw Год назад
Same I was also thinking the same 😢 but not very sure about it
@gnaniprasadreddythumukuntl3831
Hi Keerthi , I think we can achieve NlogN time complexity using recursive approach (Correct me if I am wrong) def max_score_Gnani(array): n = len(array) if n == 1: return 0 index = find_partition(array) array1_sum = sum(array[:index]) array2_sum = sum(array[index:]) if(array1_sum < array2_sum): return array1_sum + max_score_Gnani(array[:index]) elif(array1_sum > array2_sum): return array2_sum + max_score_Gnani(array[index:]) else: return array1_sum + max(max_score_Gnani(array[:index]) , max_score_Gnani(array[index:])) def find_partition(array): n = len(array) if n == 1: return 0 sum_array = sum(array) min_diff = sum_array index = -1 for i in range(len(array)): new_min_diff = abs(min_diff - (2 * array[i])) if min_diff > new_min_diff: min_diff = new_min_diff index = i print(index+1) return index+1 print(max_score_Gnani([5 , 5, 5,5 , 5 ,5, 5, 5,5 , 5, 5, 5, 5])) Every time we will half the array but in worst case we use two halves - if we have N worst cases - N * logN
@ueditz6807
@ueditz6807 2 года назад
We want STRIVER (Raj) this time...it would be amazing.💯
@withoutyt
@withoutyt 2 года назад
Hi Keerti, I think first line of the score function should return 0 instead of stones[l], because when the left==right, it will contribute 0 in the score
@harshitpaliwal2998
@harshitpaliwal2998 2 года назад
Thank you Keerti for this wonderful mock , learning alot. Although I'm a beginner but still enjoying and trying to understand . Here is a request , Can you please bring a DSA interview with Rohit Negi (Uber) ?
@KeertiPurswani
@KeertiPurswani 2 года назад
Will ask him for sure! 😇
@ashokmolagavalli5755
@ashokmolagavalli5755 2 года назад
Nice Interview . Btw Fraz already made a video explaining this problem on his channel a year ago . 😅
@adityasai550
@adityasai550 2 года назад
can you share the link to that video
@ashokk2002
@ashokk2002 2 года назад
@@adityasai550 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ysmpcUCW0sM.html
@shrayjain1358
@shrayjain1358 2 года назад
Really enjoyed the interview....I was also solving up the question with Fraz and the video became more interesting when kreeti was pointing out what is wrong here think about it and I was also thinking the same.... Really enjoyed it 😊 keep making more videos like this 😌
@kunalsharma1621
@kunalsharma1621 2 года назад
🔥🔥🔥 O(n) solution 🔥🔥🔥 We can use binary search on prefix sums for discarding in log(n).. because prefix sum will be sorted array and balance point will be min { left of (prefix sum // 2), right of (prefix sum // 2), (prefix sum // 2)} And the total discard count will be log(n) Total complexity= O(log(2n)) + O(n) for prefix sum . O(n) in total.
@PankajKP
@PankajKP 2 года назад
Please continue design pattern series?
@AmitKumar-xr6cy
@AmitKumar-xr6cy 2 года назад
the subtle face that you keep during these videos gives an actual feel of the interview
@prajwal_bagewadi
@prajwal_bagewadi 2 года назад
for a guy who is just thinking of Learning Dsa ..🙏❤
@GeniuslyTensai
@GeniuslyTensai 2 года назад
Didi please bring up more system Design mock interviews as well
@KeertiPurswani
@KeertiPurswani 2 года назад
Yes, one is already recorded. Coming this weekend! ❤️
@themayankgoyal_
@themayankgoyal_ 2 года назад
Honestly this is the best mock interview i ever watched 😍 lots of learning
@suyashsaurabh2959
@suyashsaurabh2959 2 года назад
Love the way you clean your camera every time you start a video 😊
@PrathapPuppala
@PrathapPuppala 2 года назад
int score = score(0, (int) Math.floor(stones.length/2), stones, stones.length, 0); static int score(int left, int right, int[] stones, int max, int score){ System.out.println("left: " + left + ", right: " + right + ", score: " + score + ", max: " + max); if(left == right || max == 1){ score += stones[left]; return score; } int leftSum = 0, rightSum = 0; for(int i = left; i < right; i++){ leftSum+=stones[i]; } for(int k = right; k < max; k++){ rightSum+=stones[k]; } System.out.println("Left sum: " + leftSum + ", Right Sum: " + rightSum); if(leftSum > rightSum){ score += rightSum; left = right; right = right + (int) Math.floor(right/2); } else { score += leftSum; right = (int) Math.floor(right/2); max = (int) Math.floor(max/2); } return score(left, right, stones, max, score); }
@sahildawara490
@sahildawara490 2 года назад
Thanks Keerti for your efforts. Can you please schedule one interview with Striver.
@aditisrivastava6499
@aditisrivastava6499 2 года назад
Really wonderful interview session. Got to learn so much. Thanks didi.
@KeertiPurswani
@KeertiPurswani 2 года назад
Thank you ❤️😇
@manikvenkat6651
@manikvenkat6651 2 года назад
Hi Keerti, can you also provide a link to this question in the description. so that we can also try to solve this in parallel.
@azhargayawi
@azhargayawi 2 года назад
Didi I am doing graduation in civil engineering but I have interest in IT Can I grow my career in IT? If yes what problems I will have to face because I don't belong to computer science and I am civil engineer
@Yashika_kalra
@Yashika_kalra 2 года назад
Yeah sure.....you can do DS & ML..👍
@SAMEERKHAN-de8dk
@SAMEERKHAN-de8dk 2 года назад
You can …there will be no problem
@SN-edits4u
@SN-edits4u 2 года назад
Need more of this sis, it's really helpful
@vaishnavigour5777
@vaishnavigour5777 2 года назад
Can you please do an interview of Striver(Raj Vikramaditya) he has recently joined Google Warsaw. He has a youtube channel "Take You Forward" . It would be an honour to watch his mock interview.
@ShaliniNegi24
@ShaliniNegi24 2 года назад
Can you please share the link to this question if it exist in any platform ? Thanks
@netediction9226
@netediction9226 Год назад
Today only I stumbled upon your video and I loved it. I've always been inside an interview first time getting a taste of I watching an interview from outside and It's very enjoyable. Loved the tips appeared in between the video. So insightful. I am just enjoying how a person thinks in a live interview. Subscribed
@bhuvneshvarma9175
@bhuvneshvarma9175 5 месяцев назад
Hi..Can't we use two pointer approach to find the balance point.i.e.increment fp when the sum till fp is less than sum till sp,and similarly decrement sp when sum till sp is less than sum till fp?
@rishav144
@rishav144 2 года назад
thanks keerti and Fraz
@nitishdogra7
@nitishdogra7 2 года назад
Thanks for share very informative interview 👍
@puneetdwivedi122
@puneetdwivedi122 2 года назад
This was a great experience mam, need such more mocks.
@harshvarshney6144
@harshvarshney6144 2 года назад
Now @fraz bhaiya with 74k+ subscribers , congratulations bhaiya
@codingwithanonymous890
@codingwithanonymous890 2 года назад
Keerti di interview se bahut anxiety ho rahi hain how to reduce it🥺
@KeertiPurswani
@KeertiPurswani 2 года назад
Mock interviews practise karke. Karte karte game type feel hone lagega 👀
@codingwithanonymous890
@codingwithanonymous890 2 года назад
@@KeertiPurswani ok will give mock interviews 😊
@crackthecode1372
@crackthecode1372 2 года назад
Keerti, can you please add qs link in description
@Lalit_Shirsath
@Lalit_Shirsath 2 года назад
Hii di please share your thoughts on Does software engineers gets fired after age 40?
@GAME-fj7js
@GAME-fj7js 2 года назад
Plzzzz take striver coding interview
@siddharthroy1389
@siddharthroy1389 2 года назад
He knows the question
@siddharthroy1389
@siddharthroy1389 2 года назад
@@Tarunkumar_Gatla actually faang ask less complex question
@siddharthroy1389
@siddharthroy1389 2 года назад
@@Tarunkumar_Gatla ok 👍
@_Vicky_08
@_Vicky_08 2 года назад
Fraz with stone...🤔🌝
@ankitghosh9873
@ankitghosh9873 2 года назад
Also at last put the question link so that we can practice
@venkateshpachigulla
@venkateshpachigulla 2 года назад
Will these kind of questions will be asked in Google interviews? I dont know DP.
@Rohityadav-tz5ec
@Rohityadav-tz5ec 2 года назад
Please suggest me i want to learn data structures so which language should I prefer
@muzamilpasha5227
@muzamilpasha5227 2 года назад
Can u start a series in component object modelling in c++...
@AhmedKhan-gz5uc
@AhmedKhan-gz5uc 2 года назад
Interview was a great learning opportunity. In fact, after I went through the question once, I was sure this could be solved by partition dp, since i had recently watched a mock interview by @striver on similiar track ( Scramble Strings ). However, the first approach taken by @fraz suprised me too. But later I realised that this problem could not be solved greedily as here the local optimum cannot be guaranteed to be globally optimal. I also enjoyed the bottom up method. 😊
@yashsalve3976
@yashsalve3976 2 года назад
Gap strategy...to fill the array diagonally...
@KeertiPurswani
@KeertiPurswani 2 года назад
Correct ✌️😇
@cs51904
@cs51904 Год назад
simple dp solution: vector prefix; int n = 0; int dp[502][502]; int fun(int i, int j) { if (i == j) { return 0; } if (dp[i][j] != -1) { return dp[i][j]; } int ans = 0; int a, b; for (int k = i; k < j; k++) { a = prefix[k + 1] - prefix[i]; b = prefix[j + 1] - prefix[k + 1]; if (a < b) { ans = max(ans, a + fun(i, k)); } else if (b < a) { ans = max(ans, b + fun(k + 1, j)); } else { ans = max(ans, a + max(fun(i, k), fun(k + 1, j))); } } dp[i][j] = ans; return ans; } int main() { prefix={}; vector nums = {6, 2, 3, 4, 5, 5}; n = nums.size(); prefix.push_back(0); int sum = 0; memset(dp, -1, sizeof(dp)); for (int i = 0; i < n; i++) { sum = sum + nums[i]; prefix.push_back(sum); } cout
@VishalGupta-nk4bw
@VishalGupta-nk4bw 2 года назад
Hello can anyone please tell me if I do Mca as distance education , is thery any problem while applying to faang or pbc... Like I'll be eligible to apply for those companies off campus na ??? Now after bca I'm going to start my job . so I'll have both job experience and distance degree (MCA Open)...
@shouvikdutta2825
@shouvikdutta2825 2 года назад
n=500, how O(n^3) works?
@RajeevKumar-qh6zh
@RajeevKumar-qh6zh 2 года назад
so many interviews present on youtube and in every interview candidate solve problem easily how is it possible ? is it fixed ?? not a fail a single time ?
@KeertiPurswani
@KeertiPurswani 2 года назад
You will find many interviews where candidates haven’t done that well.
@RajeevKumar-qh6zh
@RajeevKumar-qh6zh 2 года назад
@@KeertiPurswani First of all thank you for replying, this interview really helpful for me
@chesswithsarang
@chesswithsarang 2 года назад
seemed Like Fraz complicated the first question. Not sure if I am right here. I feel there could be easier way to solve it. 1. add all the elements in given array -25 is the sum 2. then divide it into 2 part ls 12 and 13 3. then find the sum from index 0 till the point we are close to to sum 12. 4. throw away the other part. 5. repeat this with the remaining array. Its just a suggestion you think this can work?
@AdilKhan-vx8qs
@AdilKhan-vx8qs 2 года назад
I was also thinking the same thing. I wonder whats wrong with it?
@AbhishekKumar-be7tx
@AbhishekKumar-be7tx 2 года назад
if(l == r) return 0; This should be there right?
@deepaksharma9874
@deepaksharma9874 2 года назад
Please can anyone provide the question link
@rakshitsahu3016
@rakshitsahu3016 2 года назад
To be honest that question is not that difficult
@RishabhRD
@RishabhRD Год назад
Link to question please?
@saurabhkarande8778
@saurabhkarande8778 2 года назад
Please make a proper roadmap with resourses links.
@jee_neetfunda3959
@jee_neetfunda3959 2 года назад
Didi aap kis nit se the?
@KeertiPurswani
@KeertiPurswani 2 года назад
NIT Calicut
@RishabhRD
@RishabhRD Год назад
Is O(n^3) for 500 even acceptable?
@Satyam_-bb5ly
@Satyam_-bb5ly 2 года назад
Matrix chain multiplication
@dennyage4791
@dennyage4791 Год назад
20:04 that case wouldn't be possible
@sksgaming993
@sksgaming993 2 года назад
Didi....software engineer ke liye roadmap pr btech ke liye and colleges suggestion....please help me didi...
@nihalmankar4743
@nihalmankar4743 2 года назад
Bring striver
@kilobyte7206
@kilobyte7206 2 года назад
good video
@bharath4330
@bharath4330 2 года назад
O(n^3) gives TLE on leetcode , it can be further optimized to O(n^2)
@siddharthjuyal6111
@siddharthjuyal6111 2 года назад
Leetcode link?
@bharath4330
@bharath4330 2 года назад
@@siddharthjuyal6111 Search Stone game V , i pasted here but looks like external links are getting deleted by bot
@sumeethaldar1056
@sumeethaldar1056 2 года назад
If they ask you this type of question in interview , I don't think they wants to hire you
@boopiechot
@boopiechot 2 года назад
def play_game(stones): def helper(stones_left, curr_score): if len(stones_left) == 1: return stones_left[0] best_score = 0 for i in range(1, len(stones_left)): first_row = stones_left[0:i] second_row = stones_left[i:] first_sum = sum(first_row) second_sum = sum(second_row) score = helper(second_row, second_sum) if first_sum >= second_sum else helper(first_row, first_sum) best_score = max(score, best_score) return curr_score + best_score return helper(stones, 0) print(play_game([6,2,3,4,5,5]))
@rudralifeandfitness
@rudralifeandfitness Год назад
Please invite Aadish Goel working in Sibros. It will be interesting.
@GeetThaker
@GeetThaker 2 года назад
Not tested, but how about it? do you think any memoization requirement here? int count = 0; private int game(int[] nums, int start, int end) { if (Math.abs(start - end) == 1) { count += Math.min(nums[start], nums[end]); return count; } int max = Integer.MIN_VALUE; int newStart = -1; int newEnd = -1; for (int i = start; i < end; i++) { int leftSum = 0; for (int j = start; j max) { max = leftSum; newStart = start; newEnd = i + 1; } } else if (rightSum < leftSum) { if (rightSum > max) { max = rightSum; newStart = i + 1; newEnd = end - 1; } } else { // they are same // do both and take maximum int sameLeft = game(nums, start, i); int sameRight = game(nums, i + 1, end); if (sameLeft > sameRight) { max = leftSum; newStart = start; newEnd = i; } else { max = rightSum; newStart = i + 1; newEnd = end; } } } count += max; return game(nums, newStart, newEnd); }
@mathematics6199
@mathematics6199 2 года назад
How many times you are computing same thing again and again Lol, its exponential dude..
@vradhibishnoi5896
@vradhibishnoi5896 2 года назад
if (l == r) return stones[0];
@KeertiPurswani
@KeertiPurswani 2 года назад
That’s not right, you will find out later in the video 😇
@vradhibishnoi5896
@vradhibishnoi5896 2 года назад
@@KeertiPurswani Ya! Now I got it... That was fun solving the question with your video. Thanks for such great mock interviews😄
@karanyadav-zi4vm
@karanyadav-zi4vm 2 года назад
@@KeertiPurswani if(l==r) return 0;
@KeertiPurswani
@KeertiPurswani 2 года назад
Great job guys! Thanks for watching the whole video ❤️
Далее
Medium Google Coding Interview With Ben Awad
51:27
Просмотров 1,3 млн
Google Coding Interview With A High School Student
57:24
Viral Video of a Man's Crazy Job Interview
16:02
Просмотров 1,5 млн