Mock Coding Interview with @iamluv - YouTuber, Competitive Programmer ๐ŸŒŸ

61,985
0
Published 2021-10-05
Have been thinking of interviewing this guy since quite some time! Asked him a hard question to really challenge him and he came up with quite different solution than what I had thought of or seen before. I hope the video is interesting to watch. Do let us know in the comments!

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)
  • @muditgupta2171
    "yeah yeah the memory is there, but we are getting O(n) solution", such a competetive coder moment xD
  • @KKKK-pl8yf
    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.
  • @pranavbhat29
    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 :)
  • @anishsuman1371
    His approach was just wow loved the way how he came up with that hashing approach
  • @AmitKumar-ll7jg
    Great content di... really loving the mock interview series. Watched all the videos. Plz never discontinue this mock interview series. โค๏ธ๐Ÿ™
  • @chetansahu1505
    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
  • @pranavbhat29
    "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 } HashSetset = 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; } }
  • @pranavbhat29
    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?
  • @mayankrai7938
    Always helpful โ˜บ๏ธโœŒ๏ธmany problems I learnt from your channel get good confidence for big product based Companies.
  • @balajiv6805
    Another nice interview, looking forward for more informative videos from you Keerti ๐Ÿ˜Š๐Ÿ˜Š๐Ÿ˜๐Ÿ˜˜
  • @yashagrawal1821
    You look sick tc. Great video thoโœŒ๐Ÿผ๐Ÿ˜… luv is too good.
  • @PROTECHRAHUL
    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.
  • @AMANGUPTA-df7hf
    In the first question can we use this approach like if (min-arr[i])>arr.size-1 increment count?