Uber Interview Question
Software EngineersCountry: United States
Interview Type: In-Person
There is another very neat alternative than creating a large boolean bucket array, radix sort.
// radix_sort is Theta(n)
def radix_sort(meetings){
// all of these, by definition will have same no digits :: max 4
no_digits = size ( meetings[0].start, 10 )
for ( inx : [no_digits-1:-1] ){
bucket = mset ( meetings ) as { int ( (str($.start))[inx] ?? 0 ) }
meetings = fold( [0:10] ,list() ) as {
continue( $.o !@ bucket )
$.p += bucket[$.o] }
}
meetings // return
}
def is_overlap(meetings){
meetings = radix_sort(meetings)
exists ( [1:size(meetings)] ) where {
meetings[$.o - 1].end >= meetings[$.o].start
}
}
Looking for interview experience sharing and coaching?
Visit aonecode.com for private lessons by FB, Google and Uber engineers
Our ONE TO ONE class offers
SYSTEM DESIGN Courses (highly recommended for candidates for FLAG & U)
ALGORITHMS (conquer DP, Greedy, Graph, Advanced Algos & Clean Coding),
latest interview questions sorted by companies,
mock interviews.
Our students got hired from G, U, FB, Amazon, LinkedIn and other top tier companies after weeks of training.
Feel free to email us aonecoding@gmail.com with any questions. Thanks!
Solution to 2/5: The number of minutes in a day is constant. Create an array of size 60*24 minutes in a day. Mark true on meeting schedules.
- aonecoding July 20, 2017