UBER | Phone Screen | L5A | San Francisco
Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2022-06-27Added By Anonymous
Source: Link
Company: Uber
Role: Senior Software Engineer
Interview Stage: Phone Screen
Location: San Francisco
Original Post Content:
Question asked for Uber Java Software Engineering Position(Phone Interview):
Convert json (with constraints) to csv
Input
1[
2{
3 "f1": "v1",
4 "f2": [{"f3": "v2"}, "v3"],
5 "f4": {"f5": ["v4", {"f6": "v5"}], "f7": "v6"},
6 "f8": ["v7", "v8", "v9", ["v10"]]
7
8 },
9{
10 "f1": "a1",
11 "f2": [{"f3": "a2"}, "a3"],
12 "f4": {"f5": ["a4", {"f6": "a5"}], "f7": "a6"},
13
14 },
15]Output:
1f1, f2.f3, f2, f4.f5, f4.f5.f6, f4.f7
2v1, v2, v3, v4, v5, v6
3a1, a2, a3, a4, a5, a6...
Constraints
•The key names are the same in all nested dictionaries.
•The values are different across dictionaries.
•The keys can be in any order in the output as long as the corresponding values are mapped to the keys.
•There is no limit to the nesting depth and there can be any arbitrary combinations of lists, dictionaries and strings.