The Disputed Fare
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- mid
Problem
A rider disputed a single charge that our billing system actually assembled from two separate ride legs, and finance needs to point to exactly which legs. Given `fares`, the leg charges in the order they were billed, and a disputed `target` total, give back the positions of the two legs whose charges add up to it, with the earlier leg first. When more than one such pair exists, return the one that completes earliest as you read left to right, and return `None` when no two legs account for the total.
Summary
One charge, two legs. Finance needs to know which two.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.