Facebook | Phone | Find if all numbers appear an even number of times & Right Side View
Anonymous User
4248

Location: Boston

Had an initial conversaton with an engineer from Facebook.

We struggled for 15 min to get the coderPad fixed and finally we did it on google doc. Interviewer asked me if its OK to go beyond the interview time and I said OK.

Question 1:
Given a list/array of integers, return a boolean that states whether all numbers appear an even number of times.

Example 1:

Input: [3, 1, 2, 1, 2, 3]
Output: true

Example 2:

Input: [1, 2, 1]
Output: false

Example 3:

Input: [1, 2, 3]
Output: false

Gave O(n) time and O(n) space complexity solution using dictionary and also proposed another solution using xor but he asked me to code the first one. Coded it.

He asked me to come up with a solution with O(1) space. I was kinda struck there and simply said inplace manipulation but he gave me a clue "sort" and then I understood he meant come up with solution with O(1) space and time complexity can increase. O(nlogn)
Coded it up and explanined. Done


Question 2:
https://leetcode.com/problems/binary-tree-right-side-view/
Standard question using BFS

Preparation : Leet code questions tagged with Facebook tag.

Still waiting for the results...

Not sure about the level, I have almost 5 years of exp
Location : Boston

Comments (15)