Phone Question:
A secure building requires people entering and exiting to scan their badges.
You are given a list of all events on a given day.
Please find the max occupancy of the building and the time that such occupancy occurs.
/** A entry/exit event recorded at building entrance */
interface Event {
String badgeId();
boolean isEntry(); // If false, event is Exit
int timestamp(); // # of seconds since midnight 0->86400
}
Example:
[“badge1”, true, 100]
[“badge2”, true, 101]
[“badge1”, false, 105]
[“badge1”, true, 107]
[“badge1”, false, 109]
[“badge2”, false, 110]Onsite Questions:
Round 1:
A friend tells you a list of airport names of his/her itinerary. But the airport names may be wrong.
Given a bidirectional graph of the airlines (between airports). The cost is the number of different characters in the airport names. For example, the right airport name is "SFO", but the given airport is "SFC", then the modification cost is 1. Output the min total cost of traversing over the itinerary.
Round 2:
2.1 Given int[] A, require |A[i]-A[j]] <= x, |i-j| <= k. Return whether the requirement is possible or not (true or false). Follow-up: duplicates are allowed
2.2 Given a list of words, find all pairs that can form palindrome
Lunch
Round 3:
Rubik's cube: Design a class to denote the cubes and implement a rotate function. This is quite an open problem and need to clarify with the interviewer while you solve the problem. This is the 1st time the interviewer asked this question, so she also refined the problem along the way.
Round 4:
BQ
Round 5:
Decode string:
ab(bcd){2}e-> abbcdbcde
ab(c(de){2}){2}f -> abcdedecdedef
Prepared quite long time for Google as I know it is hard. I am fine with most of the problems except onsite round 1. I guess the interviewer of that round gave me a no-hire rating :(