Coding
The question was pretty simple:
Q: Given two unsorted integer arrays a and b, where a has enough placeholder positions at the end to hold all elements of b, merge b into a and sort the final array in ascending order.
Example:
a = [5, 1, 3, 0, 0, 0]
b = [6, 2, 4]
result:
a = [1, 2, 3, 4, 5, 6]
Additional constraints:
- Both a and b are unsorted
- a has enough placeholder positions at the end to hold b
- The final result needs to be placed in a
- There was no explicit requirement that you couldn't use extra space / had to be O(1) space
- The final result needs to be in ascending order
System Design
Q: Design a system where a user's mobile app periodically sends their location to the server, and the system sends a notification message to all users within a given radius x.
Things to consider:
- The mobile app periodically sends its location
- The server receives and saves the user's latest location
- Given a latitude/longitude and a radius x, find nearby users
- Send a notification to all users within radius x
- How often locations get updated
- Real-time requirements for notifications
- Scalability when a large number of users update their location at the same time
- Location data expiring / stale data
- Notification delivery
Things you could clarify further during the interview:
- How often does a user's location update?
- What's the latency requirement for notifications?
- Roughly what range is x?
- Roughly what's the user scale and location-update QPS?
API Design
There were three pages, and I needed to design the corresponding APIs.
Page 1 — Course List
Shows all courses, and whether each course is completed.
For example, it needs to return:
- Course ID
- Course Name
- Completed
API: GET /courses
Page 2 — Module List
After the user picks a course, show all modules under that course, and each module's completion progress.
For example, it needs to return:
- Module ID
- Module Name
- Completed Lessons
- Total Lessons
- Progress
API: GET /courses/{courseId}/modules
Page 3 — Lesson List
After the user picks a module, show all lessons under that module, and whether each lesson is completed.
For example, it needs to return:
- Lesson ID
- Lesson Name
- Completed
API: GET /modules/{moduleId}/lessons
If the pages support the user updating completion status, you also need a corresponding update API, for example:
PUT /lessons/{lessonId}/completion
For each API you needed to spell out:
- Request parameters
- Request body (if any)
- Response format
- Authentication / user identity
- Error response
Overall impression: Coding was pretty simple; System Design leaned toward location + geospatial query + notification; API Design was the fairly common Course → Module → Lesson three-tier structure.
Discussion
Loading comments…