Google L3 interview question | Virtual Onsite 1 | Taipei, Taiwan
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2025-04-23Added By Anonymous
Source:Ā Link
š§ Experience: unknown
ā Outcome: unknown
š° Compensation: unknown
š Location: Taipei, Taiwan
š¢ Company: Google
š Education: unknown
š Benefits: unknown
š Offer Date: unknown
Virtual onsite round 1: At first the interviewer asks me how to sort by x in a list of pair (x, y) a.sort(key= lambda x:x[0]) And comes the follow up question ---- There are 2 lists A and B containing (x, y) pairs of the same length, A= [(x1, y1), (x2, y2),...,(xn, yn)] B= [(x'1, y'1), (x'2, y'2),...,(x'n, y'n)] x in A and B are nondecreasing order x1<=x2<=x3 ...<=xn x'1<=x'2<=x'3 ...<=x'n for index 0<=i<n we also want to make a[i][1]<b[i][1] What do we do? test case1 a= [(1, 0), (1, 1), (1, 7), (1, 5) ] b= [(1, 7), (1, 9), (2, 3), (4, 1) ] #in this case you can rearrange a a= [(1, 5), (1, 7), (1, 1), (1, 0)] b= [(1, 7), (1, 9), (2, 3), (4, 1) ] test case2 a= [(1, 0), (2, 1), (3, 7), (3, 5) ] b= [(2, 7), (2, 9), (2, 3), (2, 1) ] #in this case you can rearrange b a= [(1, 0), (2, 1), (3, 7), (3, 5) ] b= [(2, 1), (2, 3), (2, 9), (2, 7) ] #invalid test case a = [(1, 0), (2, 1), (3, 7), (4, 5)] b = [(2, 7), (3, 0), (4, 3), (5, 1)] If you cannot find valid a and b, raise exception I can't come up with optimal solution... Does any one have any idea?
ā Outcome: unknown
š° Compensation: unknown
š Location: Taipei, Taiwan
š¢ Company: Google
š Education: unknown
š Benefits: unknown
š Offer Date: unknown
Virtual onsite round 1: At first the interviewer asks me how to sort by x in a list of pair (x, y) a.sort(key= lambda x:x[0]) And comes the follow up question ---- There are 2 lists A and B containing (x, y) pairs of the same length, A= [(x1, y1), (x2, y2),...,(xn, yn)] B= [(x'1, y'1), (x'2, y'2),...,(x'n, y'n)] x in A and B are nondecreasing order x1<=x2<=x3 ...<=xn x'1<=x'2<=x'3 ...<=x'n for index 0<=i<n we also want to make a[i][1]<b[i][1] What do we do? test case1 a= [(1, 0), (1, 1), (1, 7), (1, 5) ] b= [(1, 7), (1, 9), (2, 3), (4, 1) ] #in this case you can rearrange a a= [(1, 5), (1, 7), (1, 1), (1, 0)] b= [(1, 7), (1, 9), (2, 3), (4, 1) ] test case2 a= [(1, 0), (2, 1), (3, 7), (3, 5) ] b= [(2, 7), (2, 9), (2, 3), (2, 1) ] #in this case you can rearrange b a= [(1, 0), (2, 1), (3, 7), (3, 5) ] b= [(2, 1), (2, 3), (2, 9), (2, 7) ] #invalid test case a = [(1, 0), (2, 1), (3, 7), (4, 5)] b = [(2, 7), (3, 0), (4, 3), (5, 1)] If you cannot find valid a and b, raise exception I can't come up with optimal solution... Does any one have any idea?