Question bank › Greedy
Dsa Greedy Medium

Gas Station Optimization

Suppose you are traveling through a series of gas stations arranged in a circular route. Each gas station has a certain amount of gas and a certain distance to the next station. Your task is to determine the minimum amount of gas needed to complete the circuit starting from your chosen gas station. You can start at any gas station. Input format: - The first line contains an integer n (1 ≤ n ≤ 100), the number of gas stations. - The second line contains n space-separated integers, representing the amount of gas at each station. - The third line contains n space-separated integers, representing the distance to the next station each station. Output format: - Print the minimum amount of gas required to complete the route. Example: Input: 4 4 6 5 8 2 2 8 4 Output: 8

Key concepts

greedyalgorithmoptimization

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.