Doordash TPS 1 - Software Engineer
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2024-01-06Added By Anonymous
Source: Link
Company: DoorDash
Role: Software Engineer (inferred from the title)
Stage: TPS 1 (Likely a technical phone screen or initial interview round)
Location: unknown
Year: unknown
Original Content:
Given a list of order ids (strictly positive, unique), return the orders in the smallest eligible order.
An order is eligible if it's strictly greater than it's immediate left and right neighbors. If there are more than one orders that are eligible, the order with smaller id takes precedence.
Example: [2]
Result: [2]
Example: [2, 4]
Result: [4, 2]
Example: [1, 4, 2]
Result: [4, 2, 1]
Provide a solution that is better than O(n^2)
Role: Software Engineer (inferred from the title)
Stage: TPS 1 (Likely a technical phone screen or initial interview round)
Location: unknown
Year: unknown
Original Content:
Given a list of order ids (strictly positive, unique), return the orders in the smallest eligible order.
An order is eligible if it's strictly greater than it's immediate left and right neighbors. If there are more than one orders that are eligible, the order with smaller id takes precedence.
Example: [2]
Result: [2]
Example: [2, 4]
Result: [4, 2]
Example: [1, 4, 2]
Result: [4, 2, 1]
Provide a solution that is better than O(n^2)