Question bank › Graphs Dfs
Dsa Graphs Dfs Medium

Robot Battery Management

A robot moves on a graph of N nodes. Moving along an edge (U, V) with weight W consumes W battery units. The robot starts at node S with K battery units. Some nodes are 'Charging Stations' that refill the battery to the full capacity K. Find if the robot can reach target node T. The robot cannot move if an edge cost exceeds its current battery. Input Format: - Line 1: N M K (Nodes, Edges, Max Capacity). - Line 2: S T (Start, Target). - Line 3: P (number of charging stations) followed by P node indices. - Next M lines: U V W (undirected edge with weight W). Output Format: - 'YES' or 'NO'. Example: Input: 3 2 10 0 2 1 1 0 1 6 1 2 6 Output: YES (Explanation: 0 to 1 costs 6, battery becomes 4. Node 1 is a charger, battery refills to 10. 1 to 2 costs 6, battery becomes 4. Reached!)

Key concepts

graphs_dfsstate_space_searchresource_management

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 InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.