Leetcode preparation
Easy problems: 64.2% Completed
Medium problems: 49.3% Completed
Hard problems: 35.3% Completed
I've been doing the LeetCode interview assesments for Facebook and also doing some codeforces problems.
Technical phone screen (1 hour)
I was asked two coding questions (no android questions):
- Given an array of n integers, return an array of n integers where at each position 0 <= i < n contains the multiplication of all the integers in the original array, except the one at the position i. This is the problem in Leetcode https://leetcode.com/problems/product-of-array-except-self/
- Given an array of n integers, return using a normal distribution any index i that belongs to the highest integer in the array. It is really similar to this Leetcode problem https://leetcode.com/problems/random-pick-index/, just that your target is the highest number in the array.
Results: Resolved both questions in less than 40 minutes and passed to virtual onsite interview
Virtual onsite interview (4 rounds)
I did pass to the next step which as you all may know, is 4 rounds of interviews. In my case they were organized this way:
2 Coding Interview, 1 Design Interview, 1 Behavioral Interview.
1st Coding round
- Given a string s return if it is either a palindrome or a palindrome + 1 extra character. Similar leetcode question: https://leetcode.com/problems/valid-palindrome-ii/
- Given an array of n integers, return its next permutation. Similar leetcode question https://leetcode.com/problems/next-permutation/
Results: Resolved both questions in less than 40 minutes. I did O(n^2) for the first one and O(nlogn) for the second one
2nd Coding round
- Given a string with parenthesis, return how many parenthesis do we need to add to make it valid. Similar leetcode question https://leetcode.com/problems/minimum-add-to-make-parentheses-valid/
- Given a string, simulate the 'deletion' of a Candy Crash in 1D. The result string should not contain two same character next to each other. Similar leetcode question https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/
Reuslts: Resolved both questions in less than 40 minutes. I did O(n) for the first one and O(n^2) for the second one
Design round
Design the Instagram home screen.
After asking some questions I got the following list of requirements:
- Authentication with Facebook
- List of posts (need to handle a large amount of posts)
- Each post has only one image
- I can like / dislike each post
- Each post shows the user's profile photo on top of them
- The app should work in offline mode (for example if I am in the airplane I should see what I already loaded)
Results: I was scaried about this round, but at the end I think I did this really good. I was able to come up with a final design talking about offline mode, about RecyclerView optimizations, how to deal with cache for images (what does libraries like Glide / Piccaso do under the hood), WorkManager, batching requests and pagination.
Behavioral round
This was mainly a conversation between the interview and I. I was asked to give examples about some specific situations in my past experiences like: 'tal about when you got an ambiguous requirement' or 'talk about when you had to work with someone you dislike'.
At the end there was a coding question: Given an array of chracters, return its number representation (ignore characters that are no numbers). Similar Leetcode question: https://leetcode.com/problems/string-to-integer-atoi/
Results: I think I did it well during the first part, I talked about my past experience and how did I face the situations I was asked to answer. I did resolve the question pretty quickly too, I think I missed some edge cases like empty spaces at the beginning, but at least the interview was apparently ok with my solution. I did O(n) solution.


