Coding 1:
Parse + validate strings for a simple language as follows :
input -> "add(1,3)"
input -> "sub(1,3)"
operations take only 2 params. commands may be nested.
ie. add(sub(3,4), 1) sub(add(238943, 2343), add(1, sub(323, 43)))
if an error is detected, report the column and what the error was
foo(1, 2) # foo is not a valid method at col 0
add(a, 3) # expecting a number or method at col 5
Coding 2:
Let's assume we have data about start and end time of Uber trips, e.g.
Case 1:
Trip 1: Start: 0, End: 5
Trip 2: Start: 1, End: 2
Trip 3: Start: 3, End: 7
Output:
0 1 -> 1
1 2 -> 1
2 3 -> 2
3 4 -> 2
4 5 -> 1
Follow up : For case like below, compact the output
[0 1]
[1 3]
[2 4]
[3 5]
[0 2] -> 1
[2 4] -> 2
[4 5] -> 1
Design
Given billions of text messages, design the index for the messages in order to efficiently retrieve messages that contain given keywords. Suppose each message can be identified and retrieved by a unique sequence number.Task 1: Design data structure to organize the keyword index.Task 2: Coding: write a method to index a given message.Task 3: Problem: each of the given search keywords are frequent (so the index list is very long) but not many messages contain all of the keywords (i.e. the intersection is small). How to improve index for multiple keywords search. For example, search for the keywords "this is a fatal disk error": most of the keywords are frequent but there may be only a few messages containing all of these keywords.
My phone: https://leetcode.com/problems/bus-routes/
Overall I found this onsite to be very hard :(


