Preparing for an interview? Check out Cracking the Coding Interview
Published on

Meta E6 Phone Screen [Rejection after providing Optimal Solutions]

Author
  • Shared Anonymously

I was asked 2 LC style questions for the phone screen by a Meta engineer. 40 mins was the time to complete both optimally. Following is what I did:

  1. Asked clarifying questions, and made sure I understood the questions completely, with good test cases which included edge cases
  2. Gave a brute force approach, followed by optimal solution approaches with TC and SC analysis (verified in LC Editorial after the interview that they were infact optimal and my TC and SC analysis were spot on). All this with little-to-No hint/support from the interviewer.
  3. After agreement from the interviewer that they were the optimal approach I started coding and completed both questions optimally within 40 mins. window
  4. Throughout the interview I gave clear explanations of the thought process, did dry runs and edge case based dry runs to explain how the solutions worked for all of those scenarios. After the interview ran the code on LC and it was Accepted for all test cases and TC and SC was optimal.
  5. The only non-ideal thing in my whole performance was, there were about 3 lines of code which were duplicated, for which I clearly mentioned that I will be able to make those lines a little more elegant if there was a couple more minutes and that I wanted to give a working solution first, for which the interviewer agreed, but didn't give me time at the end of the interview to ask how I would improve/de-duplicate the 3 lines - so I thought it wasn't a big deal for him.
  6. Not a single behavioral or other questions were asked by the interviewer - after 40 mins of coding he asked if I had any questions which we spoke about for next 5 mins, and ended the enitre phone screen within 45 mins.

I was 99% sure that I was moving on to the onsite rounds, but got a Rejection email. The feedback I got was that, I did an excellent job on the first question, but then there was code duplications on the 2nd question - the same 3 lines of code which I mentioned in the interview that I could improve if given a couple more mins. I have a rich work experience of 14 years building large scale systems leading large teams of engineers for Fortune 50 companies, and I can't fathom what I was rejected for in this interview after having prepared with 500+ LC questions (300+ Facebook tagged); I got 5/5 stars on all 8 Mock interviews that I did prior to this. They will happily hire someone with no systems experience as long as the 2 code questions look satisfying - is there no weightage for your expertise/experience/credentials/accomplishments? I have never had luck with Asian interviewers, but I thought they just can't deny me this time, but here I am writing this post.

Edit:
Since there was a lot of curiosity about what the question was, and what my code was, I am adding it below:

Question was to merge 3 sorted lists (not K), using 3 pointers approach (ask was to NOT use MinHeap), and to avoid duplicates in the output, while carefully handling the pointers since the 3 lists can be of different sizes. This was my code:

When they said I have code duplication, I assume it was the 3 lines I have commented with "// duplicate?".

    private static final int LARGE_VALUE = Integer.MAX_VALUE;  
  
    public List<Integer> mergeThreeSortedListsAvoidingDuplicatesUsingThreePointers(int[] a, int[] b, int[] c) {  
        List<Integer> output = new ArrayList<>();  
  
        int lengthA = a.length, lengthB = b.length, lengthC = c.length;  
  
        int total = lengthA+lengthB+lengthC;  
  
        int pointerA = 0, pointerB = 0, pointerC = 0;  
  
        for( int i = 0; i < total; i++ ) {  
            int itemA = pointerA < lengthA ? a[pointerA] : LARGE_VALUE;  
            int itemB = pointerB < lengthB ? b[pointerB] : LARGE_VALUE;  
            int itemC = pointerC < lengthC ? c[pointerC] : LARGE_VALUE;  
  
            if ( itemA <= itemB && itemA <= itemC ) {  
                if ( output.size() == 0 || output.get(output.size()-1) != itemA ) { output.add(itemA); }  // duplicate?  
                pointerA++;  
            } else if ( itemB <= itemA && itemB <= itemC ) {  
                if ( output.size() == 0 || output.get(output.size()-1) != itemB ) { output.add(itemB); } // duplicate?  
                pointerB++;  
            } else if ( itemC <= itemA && itemC <= itemB ) {  
                if ( output.size() == 0 || output.get(output.size()-1) != itemC ) { output.add(itemC); } // duplicate?  
                pointerC++;  
            }  
        }  
  
        return output;  
    }  

They dont all have exactly the same lines. Given another extra 30-60 seconds, I could've easily changed it to the following to reduce duplicative code (if only the interviewer gave me an opportunity to do that, or at least asked me how I would optimize it via words - he didn't ask anything. I had no clue he was going to reject me for that):

  
  
            int itemToAdd = -1;  
  
            if ( itemA <= itemB && itemA <= itemC ) {  
                itemToAdd = itemA;  
                pointerA++;  
            } else if ( itemB <= itemA && itemB <= itemC ) {  
                itemToAdd = itemB;  
                pointerB++;  
            } else if ( itemC <= itemA && itemC <= itemB ) {  
                itemToAdd = itemC;  
                pointerC++;  
            }  
  
// ensure duplicate items are not added to the output by looking at the last item  
            if ( output.size() == 0 || output.get(output.size()-1) != itemToAdd ) { output.add(itemToAdd); } // moved to the end to reduce duplication  
  

Thoughts on whether this was bad enough for a Screning rejection? Thoughts on what I could've done better?
I hope this helps someone, but I feel like I was purely SOL in this case - cos I prepared against all odds for this interview without even moving the date even after having our little one admitted to ER for a whole week before the interview, dealing my wife's car's flat tire and stranded problem just before the interview day, cancellation of kid's school right on the morning of interview after taking him all the way to school due to teacher shortage - man what not, I felt like the universe conspired against me with this even though I gave my everything. I felt good after the interview cos I thought I did it against all these odds and moved 1 inch closer, but was gutted to know I didn't 3-4 days later.

ReportMark as Helpful