Mock Coding Interview with @iamluv - YouTuber, Competitive Programmer ๐
61,985
Published 2021-10-05
Thank you โช@iamluvโฌ fir doing this!!
Use this link to check out CodingNinjas courses - bit.ly/3iAjsCv
The video contains following parts-
0:00-0:13 - Introduction
0:13-0:48 - CodingNinjas Promotion
0:48-2:20 - Question
2:20-22:40 - Solution build up and thought process with dry run
22:40-28:00 - Discussion to try space optimisation
28:00-36:40 - Code
36:40-38:48 - Corner Case that we both missed
38:48-40:15 - Feedback
You can get ๐๐๐๐๐๐๐๐๐ using code "KEERTI" -
โก๏ธ On ๐๐จ๐๐ข๐ง๐ ๐๐ข๐ง๐ฃ๐๐ฌ - bit.ly/CodingNinjas-12
โก๏ธ On ๐๐ง๐ญ๐๐ซ๐ฏ๐ข๐๐ฐ๐๐๐๐๐ฒ - get.interviewready.io/?_aff=KEERTI
โก๏ธ On ๐๐๐ฎ๐๐๐ญ๐ข๐ฏ๐ - educative.io/keerti
โก๏ธ On all ๐๐๐๐ค๐ฌ๐ ๐จ๐ซ๐๐๐๐ค๐ฌ paid courses - practice.geeksforgeeks.org/courses
You can also connect with me on-
๐๐ง๐ฌ๐ญ๐๐ ๐ซ๐๐ฆ (for not so professional, chill side of my life) - www.instagram.com/keerti.purswani/?hl=en
๐๐๐ฅ๐๐ ๐ซ๐๐ฆ Channel - t.me/keertipurswani
๐๐ฐ๐ข๐ญ๐ญ๐๐ซ - twitter.com/KeertiPurswani?s=09
๐๐ข๐ง๐ค๐๐๐๐ง - www.linkedin.com/in/keertipurswani/
#MockInterview #CompetitiveProgramming #interview #preparation
All Comments (21)
-
"yeah yeah the memory is there, but we are getting O(n) solution", such a competetive coder moment xD
-
To all viewers who can watch mock interviews without being scared..u all strong hearted people deserve my respect..hats off! ... every time i watch a mock interview it feels so fucking scary i directly jump to leetcode to practice more xD
-
one way to do that is , whenever you find a number duplicated more than once , you can set the hashmap[number] = 1 , and then consider the rest as part of the answer , because whatever happens we know that if number is duplicated C times , we know for sure that C-1 operations will be needed .
-
Good you discussed the edge case too. One solution is to simply binary search at each index which is always n log n and doesn't depend on the values of A[i]. To handle duplicates, we can do this thing on an unique array i.e. remove duplicates before doing the binary search. After that we traverse every index of that unique array and check that how many indexes on the right of it are covered by binary search with the upper bound as A[curr_index] + n - 1. All the rest of the elements needs to be changed. Also, thanks for doing it. It takes lots of efforts.
-
Also thank you so so much for making such mock interviews. I am imagining myself being an interviewee and getting goosebumps while trying to think of an answer.... I would highly recommend this channel and the mock interviews ( including the system design mock interviews ) for anyone looking to become more confident in interviews :)
-
His approach was just wow loved the way how he came up with that hashing approach
-
Great content di... really loving the mock interview series. Watched all the videos. Plz never discontinue this mock interview series. โค๏ธ๐
-
Hashing can drastically bring the TC from O(N^2) to O(N) but with a cost which is if Arr[i]>10**6 then the code will collapse. So with the constraints available on leetcode(same question obviously) the optimized TC comes down to O(NlogN) and SC to O(N). In my opinion this question doesn't qualify to be in the hard section of leetcode. Here is a piece of code that qualified AC. def minOperations(self, nums: List[int]) -> int: innitial_size = len(nums) nums = sorted(list(set(nums))) unique_array_size = len(nums) maxi = 0 for i in range(unique_array_size): pos = bisect.bisect_left(nums,nums[i]+innitial_size) if pos>=len(nums) or nums[pos]!=(nums[i]+innitial_size-1): pos = pos-1 else: pos = pos elements_within_range = (pos-i)+1 maxi = max(maxi,elements_within_range) elements_off_range = innitial_size-maxi return elements_off_range
-
"I look so stupid kya"... That was hilarious :D. Having been on the interviewer seat. I too have heard stuff like these, especially when part of campus hiring events :D
-
For the edge case, we can simply maintain 0 or 1 like the element is present or not because if any element is present more than one time then its duplicates must need to be converted to some other number. However, the approach discussed will give a TLE on LeetCode as it will depend on the maximum number in the array that is given as 1e9. This is the code for the approach discussed: class Solution { public int minOperations(int[] nums) { int n = nums.length; int mini = nums[0]; int maxi = nums[0]; for(int i = 0;i < n;i++){ mini = Math.min(mini,nums[i]); //1 maxi = Math.max(maxi,nums[i]); //1000 } HashSet
set = new HashSet<>(); for(int num: nums){ set.add(num); } int ans = n; int curr = 0; int num = mini; int k = 0; for(num = mini,k = 0;k < n;k++,num++){ if(!set.contains(num)){ curr++; } } ans = Math.min(ans,curr); while(num <= maxi){ if(!set.contains(num)){ curr++; } if(!set.contains(num-n)){ curr--; } ans = Math.min(ans,curr); num++; } ans = Math.min(ans,curr); return ans; } } -
Di your content is so amazing. Every new video just introduces new way of solution.
-
Not sure if you have covered this already as a part of the feedback ( since I am commenting as I am watching ), but at 12:02, I felt that asking the interviewer an example again when the interviewer asks you an example is something which could have been avoided. Ideally it would be good if in the beginning of the interview, the candidate enumerates all possible edge cases he/she can think of. Thoughts?
-
These sessions and learnings are so helpful. Thank you so much to both.
-
Always helpful โบ๏ธโ๏ธmany problems I learnt from your channel get good confidence for big product based Companies.
-
Another nice interview, looking forward for more informative videos from you Keerti ๐๐๐๐
-
You look sick tc. Great video thoโ๐ผ๐ luv is too good.
-
These interviews boosted my confidence a lot
-
I was just watching his stl series ans i got this video , what a timing ๐
-
Can you post the link to question if it is present in any platform? that would be really helpful.
-
In the first question can we use this approach like if (min-arr[i])>arr.size-1 increment count?