Uber | Technical Phone Screen | Build User Action Tree

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2021-11-28Added By Anonymous
Source: Link

Company: Uber
Role: software engineer i, software engineer ii
Interview Stage: Technical Phone Screen
Location: unknown
Year: unknown

Original Post Content:

When users visit a website, the actions they can take are like following.

|---register_button (10) # it means 10 users clicked register_button
| |---register_email (5)
| | | | |---email_already_exists ( 2)
| | |---register_success (3)
| |---register_facebook (4)
| | |---register_success (3)
| |---dropoff (2) # dropoff means that the user clicked the register button but then dorpped off after
|---login_button (10)
| |---login_email (4)
| | |---login_success (4)
| |---login_facebook (4)
| | | |---login_success ( 3)
| | |---login_failure (1)
| |---dropoff (2)

# given a string ,build a tree like above
intput_string =

100, 1000, A # user_id, time_stamp, action
200, 1003, A
300, 1009, B
100, 1026, B
100, 1030, C
200, 1109, B
200, 1503, A

# build the following tree
   
|---A (2)
| |---B (2)
| | |---C (1)
| | |--- A (1)
|---B (1)

Does any one know how to solve this ?

Comments