Connect JSON Coordinates Through a Documented Drawing API
Company: Stripe
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Onsite
Design a small program that reads JSON coordinate data and calls a provided drawing API to connect the points into a map or line drawing. Explain how you would interpret the input, construct the documented request body, and handle API failures.
### Constraints
The API name, endpoint, authentication, request schema, coordinate reference system, and connectivity rules are not supplied. The implementation environment provides API documentation and a sample body; inspect those before choosing field names. This is a real-API integration task, not a portable algorithm console.
### Clarifying Questions
- Are the coordinates Cartesian positions or geographic coordinates, and what is their order and unit?
- Should points be connected in input order, grouped into paths, or joined according to explicit edges?
- Does the API accept a whole path or separate segments, and is the final point connected to the first?
- Which failures may be retried, and can a repeated request duplicate a drawing?
```hint Validate a small path against the documented body
A coordinate pair can be syntactically valid JSON while still having its axes or units reversed for the API.
```
### What a Strong Answer Covers
- JSON/schema validation and an explicit connectivity interpretation.
- A request adapter based on the provided API contract and sample.
- Error handling, retry/idempotency policy, and verification of the actual drawing result.
### Follow-up Questions
- How would you handle several disconnected paths in one input?
- How would you recover if the API accepted a request but the response was lost?
Overview: Plan coordinate parsing and drawing-API integration with explicit geometry semantics, request mapping, error handling, and idempotent recovery.
Design a small program that reads JSON coordinate data and calls a provided drawing API to connect the points into a map or line drawing. Explain how you would interpret the input, construct the documented request body, and handle API failures.
Constraints
The API name, endpoint, authentication, request schema, coordinate reference system, and connectivity rules are not supplied. The implementation environment provides API documentation and a sample body; inspect those before choosing field names. This is a real-API integration task, not a portable algorithm console.
Clarifying Questions Guidance
Are the coordinates Cartesian positions or geographic coordinates, and what is their order and unit?
Should points be connected in input order, grouped into paths, or joined according to explicit edges?
Does the API accept a whole path or separate segments, and is the final point connected to the first?
Which failures may be retried, and can a repeated request duplicate a drawing?
What a Strong Answer Covers Guidance
JSON/schema validation and an explicit connectivity interpretation.
A request adapter based on the provided API contract and sample.
Error handling, retry/idempotency policy, and verification of the actual drawing result.
Follow-up Questions Guidance
How would you handle several disconnected paths in one input?
How would you recover if the API accepted a request but the response was lost?