MICROSOFT Coding Interview | Getting Interviewed by a Microsoft Engineer

Поделиться
HTML-код
  • Опубликовано: 14 окт 2024

Комментарии • 209

  • @arishsheikh3000
    @arishsheikh3000 2 года назад +197

    It should be row++ instead of col++

    • @mohammadfraz
      @mohammadfraz  2 года назад +44

      Yes thanks for the correction

    • @shanmukha599
      @shanmukha599 2 года назад +5

      Yes same doubt raised to me thank you👍

    • @ankushmudgil9352
      @ankushmudgil9352 2 года назад +1

      Yes i also found that error

    • @singiri697
      @singiri697 2 года назад +1

      Moving backwards increments the rows,?

    • @lokeshborole8997
      @lokeshborole8997 2 года назад

      ​@@ankushmudgil9352 so smrt😅

  • @subhamshaw7755
    @subhamshaw7755 8 месяцев назад +2

    we can also use a base case if(targ < a[0][0] || targ > a[n-1][n-1]) return false;

  • @codencode5546
    @codencode5546 2 года назад +53

    Sir first of all thanks to you and Kushal Sir to feel the Enviroment of a Real Interview and I can solve all the 2 Questions so I'm Happy that my Efforts are worth it!!

  • @ahmedbahri5115
    @ahmedbahri5115 Год назад +4

    for the first question there is a faster approach , you have to use the sorting more efficiently, there is this O(log n+m ) solution :
    class Solution:
    def searchMatrix(self, matrix: List[List[int]], target: int) -> bool:
    right = len(matrix[0]) -1
    bottom = len(matrix)-1
    top ,left=0,0
    def searchHelper(matrix,top,bottom,left,right,target,visited):
    if top > bottom or left > right:
    return False
    mid1=(top+bottom)//2
    mid2=(left+right)//2
    if (mid1,mid2) in visited :
    return False
    visited.append((mid1,mid2))
    if matrix[mid1][mid2] == target :
    return True
    if matrix[mid1][mid2]>target:
    return searchHelper(matrix,top,bottom,left,mid2-1,target,visited) or searchHelper(matrix,top,mid1-1,left,right,target,visited)
    else:
    return searchHelper(matrix,top,bottom,mid2+1,right,target,visited) or searchHelper(matrix,mid1+1,bottom,left,right,target,visited)

    return searchHelper(matrix,top,bottom,left,right,target,[])

    • @AjaySingh-us1ku
      @AjaySingh-us1ku 8 месяцев назад

      using recursion is not always a good thing, but yes it can be optimized to 1 more layer using iterative approach.

  • @devanshmesson2777
    @devanshmesson2777 2 года назад +24

    Much needed videos like this!
    Just want to thank you for this!
    Telling the approach in an interview is a skill, thank you for guiding us about how to give an interview!

    • @mohammadfraz
      @mohammadfraz  2 года назад +3

      Thanks a lot for appreciating ☺️, hope it helps

  • @artemsydorchuk4711
    @artemsydorchuk4711 Год назад +2

    For the first problem, is the solution with binary search better?
    We can start from the middle in the mattrix, like from the centre of the quadrate and based on the value get rid from all left bottom values or right upper. Than define the middle of new quadrate and repeat a procedure. Time complexty in this case will be O(log(n*m)) which is much better.

  • @ankursharma6084
    @ankursharma6084 2 года назад +58

    Nicely explained , both problems are from this month's leetcode daily challange 😃😃

    • @mohammadfraz
      @mohammadfraz  2 года назад +5

      Thanks ☺️

    • @learnenglish699
      @learnenglish699 2 года назад +2

      hello ankur sharma bhai ek baat puchne thee pls are u there?

  • @KushalVijay
    @KushalVijay 2 года назад +23

    Great conversation with you Fraz, Excited for our next mock interview on my channel. ❤️🔥

    • @mohammadfraz
      @mohammadfraz  2 года назад +4

      Yess 🔥 , excited for your turn.

    • @sureshdhakad9854
      @sureshdhakad9854 2 года назад +5

      You could have given your detailed feedback at the end of the interview then only it will be helpful for the people who are preparing for interviews.
      Like always ask clarifying question before start discussion the solution.
      I am also taking interviews at my org and find that candidate doesn't ask clarifying questions and also they just jump on coding and doesn't discuss the solution before writing the code.
      These are my expectations as an interviewer:
      1. Candidate should ask clarifying question before discussing the approach to solve the problem.
      2. Candidate should confirm with the interviewer if the approach looks good then only start the coding.
      3. Candidate should think and code loudly so that if he/she get stuck then interviewer can give some hint.
      4. Always try to write optimized code.
      5. Never give up in an interview and seek hint/help if get stuck somewhere. don't seek more than 2 hints.
      6. Consider edge cases and dry run the code with at least 2-3 test cases.

  • @Nohesitation666
    @Nohesitation666 2 месяца назад +1

    In interviews.. code is said to be written in notepad.. to see if he knows everything or not... In vs code or other softwares, autocorrect is done and auto organisation with different colours are found which makes coding easier.. in notepad we have look for all brackets and commas

  • @abdussamad0347
    @abdussamad0347 2 года назад +17

    I recently practiced both the questions on leetcode. You did it very well. I think in the last question . The duplicates for first loop i.e for i should be the check of arr[i] and arr[i+1]. The for loop itself will handle the last increment.

    • @mohammadfraz
      @mohammadfraz  2 года назад +3

      Yes i was doing about to the same after discussing space and time but then we concluded it

    • @poorpanda9033
      @poorpanda9033 11 месяцев назад

      Can you send the leetcode link for these questions ?

  • @rishabhraj9802
    @rishabhraj9802 2 года назад +6

    10:40 @fraz the reason you are giving that you will be able to move in two directions is a assertion not a reason. Reason is you can stand either on four corners or in between the array, inbetween you will have conflicting choices as incrementing row or col will result in bigger values and vice versa but when you start from top right or bottom left you have two non conflicting choices, if you go left you decrease, down increase and vice versa foe other situation

    • @mohammadfraz
      @mohammadfraz  2 года назад +3

      Exactly 😊.
      This is the reason why we can only start from top right or bottom left.

    • @rishabhraj9802
      @rishabhraj9802 2 года назад

      @@mohammadfraz The way you took it man hats off, shows why you have so many submissions on leetcode.

  • @pranshuprapranshu304
    @pranshuprapranshu304 Час назад

    Instead of storing the result in set better to store all elements of array in set then there will be no possibility of repetition and no need of checking every time whether it's a duplicate triplate or no

  • @manojsv8252
    @manojsv8252 2 года назад +6

    I think we can reduce the for loop iterations a bit in case we have many numbers by having a condition "nums[i]

  • @aakashshelake
    @aakashshelake 5 месяцев назад +2

    You can treat whole matrix as 1d array
    Where low = 0, high = n * m - 1
    And do binary search
    We can find row and col like
    Mid/m , mid%m res.

  • @akshatmahajan2692
    @akshatmahajan2692 2 года назад +15

    really helpful more similar videos would definitely boost the confidence before campus placements

  • @244_debajitdatta
    @244_debajitdatta 2 года назад +2

    Max possible min time complexity is
    (Logm+logn)
    If we modify the binary search

  • @LalitSingh-gu3dt
    @LalitSingh-gu3dt 2 года назад +3

    inplace of col++ will be col- - And similarly inplace of row-- will be row++

  • @subhamengine1143
    @subhamengine1143 2 года назад +2

    Just heard your approach and tried to code myself on LC, and it was correct in the first attempt.

  • @shatadal_das
    @shatadal_das Год назад

    Sir, I solved the first question in O(log (n*m)) complexity by applying Binary search in the last column and Binary Search in the row in which the target may be present.

  • @saswatsenapati7870
    @saswatsenapati7870 Год назад

    Great video of the mock.
    Just one highlight point, clarifying questions can be better, for example in triplet question you could have asked do i have to return all the triplets or just one, or what return value is expected the triplet values or its indexes or just a boolean.

  • @dollyyadav3251
    @dollyyadav3251 2 года назад +8

    keep doing good work👏👏like each & every video of yours. Amazing content, u r providing a great guidance to each one of us😃

  • @siddhantkhare2775
    @siddhantkhare2775 2 года назад +68

    Microsoft Engineer using GOOGLE Docs:

    • @shyam_mahadevan
      @shyam_mahadevan 11 месяцев назад +1

      Document is not important or any paper its about the concept which is required

    • @Nohesitation666
      @Nohesitation666 2 месяца назад

      In interviews.. code is said to be written in notepad.. to see if he knows everything or not... In vs code or other softwares, autocorrect is done and auto organisation with different colours are found which makes coding easier.. in notepad we have look for all brackets and commas

    • @siddhantkhare2775
      @siddhantkhare2775 2 месяца назад +1

      @@Nohesitation666 Yes and also indentation is an advantage in other code editors...🙂

  • @TheZorboidOrbb
    @TheZorboidOrbb Год назад +2

    Good video but even before starting with your brute force approach, you should have got some clarifications out of the way. Like
    1. Are all elements positive?
    2. Whole numbers?
    3. Are all elements unique?
    Approaching a solution without getting all the cases and conditions is a strict no. Since this is a mock, you should be very careful in what you teach others.

  • @apurbaghosh5540
    @apurbaghosh5540 2 года назад +5

    1st ques is asked in my one of interview in my placement session 😍😍

  • @stuart3565
    @stuart3565 2 года назад +3

    i really liked this mock interview please upload more video like this it helps to prepare
    bhaiya can i crack the google and microsoft beacuse recently i have started learning dsa from scracth and i am in mid of the 5th sem but i am facing problem while solving questions in optimized way most of the times i watch the solution

  • @divine5863
    @divine5863 2 года назад +4

    We need more videos like this

  • @razataggarwal7365
    @razataggarwal7365 Год назад

    Question 1 can be solved with O(M+N) TC and constant space.

  • @ritwikshivam1203
    @ritwikshivam1203 2 года назад

    In the first question, it should be col-=1 and row+=1, coz we are coming down to next row if target>current element else 1 col backwards?
    Amazing video btw

  • @prajwal2005
    @prajwal2005 2 года назад +1

    First of all thank you for making the video. I have a question for the 1st problem.
    If you had a matrix say
    1 , 2, 3, 4
    5, 7, 9, 13
    6, 8, 10, 11
    How would it solve if target is 11 ?
    Say we start from 4 , target is large and so we move down to 13, target is smaller so we move to 9, target is larger so we move down to 10 and now since the target is larger we go out of the array and return false.
    We just can not move around down and left .. we also need to consider when should we move right and up.
    And that would increase the complexity as every time the bound increases beyond the matrix limit we will need to take a decision of either to move either up or right.
    And in worse case I guess we will end up with m×n complexity ?
    Am I right ? Or may be it leads to an endless loop ..hmm

    • @shivamjain5656
      @shivamjain5656 2 года назад

      Hi Prajwal...the condition was both the rows and column are sorted, but the matrix you have made I see that your last column is not sorted

    • @prajwal2005
      @prajwal2005 2 года назад

      @@shivamjain5656 ahh yes. Thanks for pointing that out. My bad

  • @roydebraj2188
    @roydebraj2188 Год назад

    its been only a week now of me learning java and i was able to ans the first question i have learnt till arrays and wasnt aware of the concept of binary search i am sure i will learn it in the future. i am writing this message because i am just happy happy hahaha

  • @tomaraditya9487
    @tomaraditya9487 2 года назад +2

    Wow bhaiyaa great video....
    The elements to be unique was the first thing clicked in my mind😇

  • @nonplussedNerd
    @nonplussedNerd Год назад

    ques 1 coptimized approach was actually using binary search, worst case the given by fraz in actually N2 if element is near right corner

  • @ShinAkuma
    @ShinAkuma Год назад

    In the first question, why not start at the middle element ?
    The travel distance will always be shortest no matter where your target element lies on the matrix. If you start at the corner and the element lies at the end of the diagonal, you've spent 2X more time than you would have if you started at the middle.

  • @developerDebanjan
    @developerDebanjan 2 года назад +1

    If only the actual level of the questions would have been like these..

  • @dynamichussain1770
    @dynamichussain1770 2 года назад +1

    bhaiya for the second question in the 3rd while loop (nums[e]==nums[e+1])it should be e-- instead of e++.

  • @pjagannadham2540
    @pjagannadham2540 Год назад

    fraz bhaiyya oo first question ka approach is really super and it's easy to understand keep sharing this knowledge bhaiyya

  • @Baba_Datna_Sayad_Peer_Ji_786
    @Baba_Datna_Sayad_Peer_Ji_786 2 месяца назад

    there should e - - instead of e ++ in loop i.e., for avoiding duplicates.😊😊😊😊😊😊😊😊😊😊😊😊

  • @subhamdasgupta3848
    @subhamdasgupta3848 2 года назад

    My one liner pythonic solution for question 2,
    [i for i in list(itertools.combinations(list(set(x)), 3)) if sum(list(i)) == k]
    P.S: This solution is only meant for fun.

  • @nandharamya9612
    @nandharamya9612 Год назад

    If all elements in Matrix is unique then we no need to bother row and column and straightaway we can do binary search tree using a single pointer right. Am I right on this understanding?

  • @aamirhannan890
    @aamirhannan890 Год назад

    Ohh bahi, ye question maine aaj hi kia LeetCode pe!.. logn + logm me ban jaayegi ye binary search se...

  • @kaustubhshrivastava3169
    @kaustubhshrivastava3169 2 года назад +2

    can you get some more medium level questions next time wich are some what harder to solve so that we can get a gist of how to handle the pressure in those situation where we are not getting to the optimal solution btw nice video😀

    • @harshsrivastava2324
      @harshsrivastava2324 2 года назад

      Interviewer questions bnata nahi hai kahi se utha ke hi lata hai except Google

  • @AJAYKUMAR-pj3zq
    @AJAYKUMAR-pj3zq 2 года назад +1

    It's great sir please upload this types of video

  • @surgeonofdeath8199
    @surgeonofdeath8199 2 года назад

    In the first question we can apply that 2-d array binary search as well using division and mod as well ..
    Won't that be actually better approach if it is sorted row wise and Column wise both

    • @BROOKnim
      @BROOKnim Год назад +1

      hmm it won't work without this constraint "every element on one row is greater than the elements on previous rows "
      If this constraint was given , we can consider the 2d array as a 1d array and Bo binary search

    • @gatecsemaster
      @gatecsemaster Год назад

      this apply when you have the whole matrix is sorted .

  • @gkthecoder9589
    @gkthecoder9589 Год назад

    can we use a membership check right..!, Weather the element is present or not.

  • @avinashkumar3340
    @avinashkumar3340 11 месяцев назад +1

    This is a cakewalk question. Are Microsoft coding interview questions this easy ?

  • @dsa0decoded
    @dsa0decoded 7 месяцев назад

    are these to boost confidence or microsoft really ask such easy questions ?

  • @livingwiththedivinesoul8335
    @livingwiththedivinesoul8335 Год назад +1

    When was it said that the array is going to be sorted in the second question?

  • @SL4UGHT3R
    @SL4UGHT3R Год назад

    In first question else statement says row - - which means you are going a row above but that doesn't make any sense. On the other hand where are you checking that target is present or not in that row if column[lastElement]>target.

  • @codenchill732
    @codenchill732 2 года назад +2

    Keep doing more such interviews

  • @piyushmathpal4244
    @piyushmathpal4244 2 года назад

    this playlist is best
    Please continue mock interview series

  • @mondal1839
    @mondal1839 Год назад

    My solution: O(n logm) where nm) swap(n,m);
    for (int i = 0; i < n; i++) {
    int index = binary_search(arr[i], i, m, key);
    if (index != -1) {
    cout

  • @dhananjaysahu9076
    @dhananjaysahu9076 2 года назад +1

    I don't think they will ask these well known questions in off campus interviews

  • @luckyloops2714
    @luckyloops2714 2 года назад

    We can use hashmap with I and j variables sliding through all of them

  • @487_sahilrout3
    @487_sahilrout3 2 года назад +1

    Wow agar sachmein is level ka aata hoga microsoft ke interviews pe tab to mera mast se nikal jyega knew both the questions 😄

    • @mohammadfraz
      @mohammadfraz  2 года назад +2

      Great 🔥 all the best Sahil

    • @sahilrout4745
      @sahilrout4745 2 года назад +2

      @@mohammadfraz Thnx bhaiya 🙌 internship season shuru hone wala hai college pe july se need this all the best

  • @AnkitMishra-ss7mw
    @AnkitMishra-ss7mw 9 месяцев назад

    Please start with an introduction

  • @ganapathi2531
    @ganapathi2531 2 года назад

    This was good, just a suggestion , it would be good if the input and output is given in docs before explaining the question by the interviewer

    • @mohammadfraz
      @mohammadfraz  2 года назад

      Sometimes interviews don't give input or output. But we can always get it clarified

    • @Labrador_Stunts
      @Labrador_Stunts 2 года назад

      @@mohammadfraz hi Fraz . Iam new to this .. what is these questions. What kind of coding is this .. is this realated to DSA?

  • @thehulk3379
    @thehulk3379 2 года назад

    i am not a programmer, just using my math knowledge.......!
    Since the columns and rows of a matrix are sorted,
    we can use conditions like
    1) A1,1

  • @PraveenKumar-nu9wk
    @PraveenKumar-nu9wk 2 года назад

    Bhaiya in the first problem ie. Find element in sorted matrix ,row and col should be interchanged.

  • @Vibedecoded
    @Vibedecoded Год назад

    Search in a 2d matrix, 3 Sum (leetcode question)

  • @greatest5902
    @greatest5902 2 года назад

    Need more videos in similar format!!

  • @phoneix24886
    @phoneix24886 2 года назад

    The first one could be done in log(m*n). nlog(m) is not optimal.

  • @yashnegi9473
    @yashnegi9473 Год назад

    thank you. It is my dream company to work for. Really appreciate all your efforts sir.

  • @KalpitSharma
    @KalpitSharma 2 года назад

    Easy Question puchha tumne , interview me humko tough ques q aatay hai :( But it really helped a lot to understand how interview should be.

  • @skmdmobinulislam9597
    @skmdmobinulislam9597 2 года назад

    Do we have to use google docs in actual interview also?

  • @someshsahu4638
    @someshsahu4638 Год назад +1

    Nice replica 👍🏼

  • @gauravgautam5963
    @gauravgautam5963 2 года назад

    When we will expect the interview to be taken by you on Kushal vijay's channel that will be to awesome

  • @brahmanandakabi8796
    @brahmanandakabi8796 2 года назад

    Thank you bro for this type of content

  • @ashishverma-gw7cc
    @ashishverma-gw7cc 2 года назад

    3rd approach will be like,
    Apply BS on 1st column, in log(#col) time we'll have the row where we can expect target element. Then in that row again apply BS to see if element is present or not, log(#col).
    total TC = log(#col) + log(#row) +O(1)

    • @BROOKnim
      @BROOKnim Год назад

      If you see the question correctly this won't work
      Consider the matrix like this
      [1,3,7]
      [2,4,6]
      [8,9,10]
      And let target be 7
      Here if you apply bs on first column, you'll get the row where ans should be present is third not first ..
      Your approch will be correct if there was this constraint " all the elements on one row is greater than elements from before rows"

  • @sanskrutikanse-fj2rc
    @sanskrutikanse-fj2rc Год назад

    Hii fraz aapko kitne coding question puche the product based company ke interview mei.can u tell

  • @Manoj_Jadhav.12
    @Manoj_Jadhav.12 Год назад +2

    Man that 3rd approach of first question was 🔥🔥

  • @notrahul9572
    @notrahul9572 3 месяца назад

    First is not optimal log(m*n) is optimal

  • @kedarkulkarni9464
    @kedarkulkarni9464 2 года назад

    I was asked the exact same 1st question for my Microsoft interview :)

  • @prettysmart3732
    @prettysmart3732 2 года назад +1

    Faraz Sir ye live kro phir bahut acha hoga btw it was great thanks a lot

  • @garigantibhanuvenkatasaikr3164
    @garigantibhanuvenkatasaikr3164 2 года назад

    very informative

  • @AnkurVashishtha01
    @AnkurVashishtha01 Год назад +1

    Good to see Virat Kohli solving problem. haha jokes aside, amazing content. subbed!

  • @PIYUSH-lz1zq
    @PIYUSH-lz1zq 2 года назад

    Yeee sahi tha !

  • @NOTOni
    @NOTOni 2 года назад

    hi
    you are having a great day TILL NOW ........

  • @saulgoodman6710
    @saulgoodman6710 Год назад

    Wait hows the first q solution correct, he didn't even perform binary search right?

  • @garigantibhanuvenkatasaikr3164
    @garigantibhanuvenkatasaikr3164 2 года назад

    very interesting

  • @TheRiddLer870
    @TheRiddLer870 2 года назад

    when should i solve your sheet after completely learning dsa or while learning
    it pls reply

  • @shubamgoswami
    @shubamgoswami 2 года назад

    ver informative

  • @AmitSharma-yi9dr
    @AmitSharma-yi9dr 2 года назад

    does top companies like microsoft accept candidates with extended education..as in b.tech completed in 6 yrs .

  • @ahmedmukhtar6961
    @ahmedmukhtar6961 2 года назад

    I didn't knew they make you write code in microsoft word? i thought we could use normal IDEs.

  • @meetshah31
    @meetshah31 Год назад

    the 1st question is so easy i just solved it in leetcode if i were in the interview im like boom

  • @sricharan7287
    @sricharan7287 2 года назад

    Why Microsoft is using Google docs🤔🤔🤔🤔🤔🤔

  • @avinashv7154
    @avinashv7154 2 года назад

    I completed btec in ECE with 7cgpa (63%). Can i apply amazon CSA role
    I had seen your video on this topic and it's my aim to get a job in CSA bro please reply

    • @mikehawk9762
      @mikehawk9762 Год назад

      i am also a fresher in ece branch?how much do we learn related to cse there?pls Reply

  • @fardeenshaikh6434
    @fardeenshaikh6434 2 года назад

    wow bhaiya bhut accha experience diya like real interview

  • @blackkurama9119
    @blackkurama9119 7 месяцев назад

    well.... why is it too easy 😭... i got way tougher question in workday interview than this

  • @madetolaugh3476
    @madetolaugh3476 2 года назад

    Interview mein leetcode wagera mein nhi hota kya coding round ?

  • @himanshugupta5812
    @himanshugupta5812 2 года назад +1

    pls increase your sound your sound was less and interviewer sound was good

    • @mohammadfraz
      @mohammadfraz  2 года назад

      It's just because our audio was recorded at his side

  • @prateekkatiyar9532
    @prateekkatiyar9532 2 года назад +1

    For question 1 your code is wrong.
    It should be-
    else if(mat[row][col] < target) row++;
    else col--;

  • @mathematics6199
    @mathematics6199 2 года назад +1

    1st question was good

  • @sudheer348Ext
    @sudheer348Ext 2 года назад

    Good try! Just keep in mind not to come to conclusion or provide a solution in the first minute or 2. take time to clarify and answer all questions and showcase with example before talking about your solution or complexity. just 2 cents!

  • @laluchouhan9163
    @laluchouhan9163 Год назад

    make a video who take a job from non tech branch

  • @PROTECHRAHUL
    @PROTECHRAHUL 2 года назад +1

    Bhaiyaa i was able to solve first question 🙂

  • @iakash017
    @iakash017 2 года назад

    thank you so much bhaiya

  • @technicalrafik7034
    @technicalrafik7034 2 года назад

    You are doing great work bhaiya Allah Bless You 💯

  • @developerDebanjan
    @developerDebanjan 2 года назад

    Thumbnail and the question is not matching

  • @newvideo4033
    @newvideo4033 2 года назад

    Plz bhaiya more video upload karo

  • @mohammadkaifdevalapur
    @mohammadkaifdevalapur Год назад

    Bhaiya i am stuck in dsa i not understanding how to complete dsa in 1 month