EV Routing, Grids & Graph BFS
- Route an EV to the cheapest charging station under a battery limit, from pruned DFS to Dijkstra
- Compute every subtree size in a tree with one BFS and a reverse pass
- Reveal a Minesweeper board with a queue and count neighbouring mines
- Count islands with a flood fill that never visits a cell twice
Rivian's coding rounds are mostly LeetCode easy to medium, and the newest reports show the problems putting on a vehicle costume. The clearest case is from a November 2026 onsite. It was one of four one-hour rounds, and the candidate's whole note on it is short. Find a path to a charging station on a 2D array, one cell per move, start with DFS, then extend it with pruning. The same loop also asked for a vehicle-to-cloud design, and the candidate tagged the result a pass.
Graph BFS is the other live thread. A Senior AI Engineer's screen in May 2026 had a quick graph problem solved with BFS. In December 2024 a senior engineer in Palo Alto was asked how many subtrees a graph has, using BFS, and one interviewer later repeated the screen question. Two older grid problems close the lesson, each with a single dated report. Minesweeper ran in a 2023 onsite. Number of Islands comes from a 2021 remote round.
How Rivian frames grid and graph problems
Rivian has no house problem that repeats loop after loop. What repeats is a shape. You get one problem in a 45 to 60 minute session, usually on HackerRank, in the language of your choice for general software roles. Embedded and controls teams can switch you to C or C++ without much warning, so ask the recruiter which language each round expects.
The charging-station round shows how the hour tends to run. You start with something that works, here a DFS that tries every route, and the interviewer pushes you to make it faster. Pruning is the first step. The clean finish on a grid with costs is Dijkstra, and it helps to know where you're heading before you start the DFS. Rivian's job postings ban generative AI tools in live interviews, so plan to write all of it yourself.
All four problems walk a grid or graph from a start, one neighbour at a time. When every step costs the same, a plain queue gives you the order. When steps cost different amounts, as with charge per cell, a min-heap ordered by total cost takes the queue's place. Pick the structure from the costs before you write the loop.
EV route to the nearest charging station
This is the November 2026 onsite problem, and the newest grid question anyone has reported from Rivian. The candidate gave only the outline: a 2D array, a car that moves one cell at a time, a path to a charging station, DFS first and pruning after. Practice write-ups of the question put a charge cost on each cell and a battery limit on the car, and the version below does the same. Treat those details as something like the real prompt, and practice the shape.
EV Route to the Nearest Charging Station
Problem
start, given as [row, col]. Each grid[row][col] is the charge it costs to drive into that cell, and -1 marks a cell the car can't enter. The car moves up, down, left or right, one cell at a time. The start cell costs nothing.chargers lists the charging stations as [row, col] pairs, and battery is the charge the car has. The car can't enter a cell that would cost more charge than it has left. Arriving with exactly zero is fine.Return the charge left when the car reaches the charger that costs the least charge to get to. If no charger is reachable, return
-1.The charger at [2,2] is fewer steps away but costs 8, because its own cell costs 5. Going along the top row and down to [2,3] costs 5, so the car arrives with 5 left.
Weighted grid shortest path. Push (charge used, row, col) onto a min-heap. The first charger you pop is the cheapest one to reach, so you can stop there.
EV Route to the Nearest Charging Station
Click "Run" to execute your code
Count subtree sizes with BFS
Two first-hand reports put graph BFS in Rivian screens. In December 2024 a senior engineer was asked "How many subtrees in a graph?" with BFS. The usual reading is every node's subtree size in a tree rooted at node 0. In May 2026 a Senior AI Engineer's screen had a quick graph problem solved with BFS, without naming it. The problem below is the subtree-size reading, and the forest count is the follow-up.
Subtree Sizes With BFS
Problem
n nodes numbered 0 to n - 1 and a list of undirected edges that connect them into one tree. Root the tree at node 0.Return a list where entry
i is the size of node i's subtree: the node itself plus everything below it. Use BFS for the traversal, so a deep tree can't overflow the call stack.Node 1 holds itself and its children 3 and 4. The root holds all five nodes.
BFS from node 0 gives every node a parent and an order where parents come before children. Walk that order backwards and add each node's size to its parent.
Subtree Sizes With BFS
Click "Run" to execute your code
Older problems (2021-2023)
The next two come from older loops, and each has one dated first-hand report. They're good practice for the same grid moves, but nothing says Rivian still asks them, so give them less time than the two problems above. A 2024 intern screen had a grid problem of its own, something like counting how many non-overlapping 2 by 2 charging stations fit on the buildable cells of a 0 and 1 grid.
Minesweeper (2023)
A software development engineer's onsite in late 2023 opened its five rounds with an algorithm round, and the candidate said it was LeetCode's Minesweeper as written. A logging-system design and behavioral rounds followed.
Minesweeper
Problem
board of single-character strings. Hidden cells are "M" for a mine and "E" for an empty cell. Revealed cells use "B" for a blank with no adjacent mines and "X" for a revealed mine. A digit from "1" to "8" marks a revealed cell next to that many mines.click is [row, col] of the next hidden cell to reveal. A mine turns into "X". An empty cell next to at least one mine shows the count. With no adjacent mines, the cell becomes "B" and all eight neighbours are revealed by the same rules.Return the board after the click. Adjacent means all eight directions, diagonals included.
The click lands on a blank, and the reveal spreads until it reaches the ring of cells that touch the mine.
BFS flood fill over eight directions. A cell with a mine count stops the spread; a blank pushes its hidden neighbours onto the queue.
Minesweeper
Click "Run" to execute your code
Number of Islands (2021)
Prep lists often rank Number of Islands as very likely at Rivian, but it has one dated first-hand report behind it. That was a November 2021 remote coding round for a software development engineer in Vancouver, in the candidate's choice of language. It's the classic flood fill, and worth twenty minutes if grids are rusty.
Number of Islands
Problem
grid of "1" for land and "0" for water. An island is a group of land cells joined up, down, left or right. Diagonals don't connect.Return the number of islands. The grid can be empty.
A 2 by 2 block at the top left, a single cell in the middle and a pair at the bottom right.
Scan every cell. Each time you meet land, count one island and sink the whole island with a BFS so it is never counted again.
Number of Islands
Click "Run" to execute your code
What earns points
Passing tests counts for a lot at Rivian. Two 2025 candidates said a few failing test cases cost them a level, and a 2021 embedded screen wanted code that compiled without warnings and passed every test. So the order of work matters. Get a correct version running, run it on the edge cases out loud, and only then go after speed, the way the charging-station round moved from DFS to pruning.
Common questions
Does Rivian ask LeetCode questions?
Yes, mostly easy to medium, one problem per session in most reports. The newest ones lean toward the car, like the November 2026 charging-station route on a grid. Classic grid problems such as Minesweeper (2023) and Number of Islands (2021) each have one dated report.
What graph and grid topics should I practice for Rivian?
BFS on a grid, BFS on a tree or graph given as an edge list, and shortest paths with Dijkstra when cells cost different amounts. Be able to start from a plain DFS and prune it, because that's how the 2026 onsite round went.
What language and platform does Rivian use for coding interviews?
HackerRank, including CodePair for live rounds, in nearly every report that names a platform. General software roles let you choose the language. Embedded, controls and autonomy teams often expect C or C++. Rivian's job postings ban generative AI tools in live interviews.
Key Takeaways
- ✓The November 2026 onsite asked for an EV route to a charging station on a grid, starting with DFS and adding pruning.
- ✓When cells cost different amounts of charge, use Dijkstra and test for the charger when you pop it.
- ✓Subtree sizes come from one BFS for parents and order, then a reverse pass adding each size to its parent.
- ✓Minesweeper (2023) and Number of Islands (2021) have one dated report each. Use them as flood-fill practice.
Rivian interview guideKnow what Rivian asks before you walk in.
28 coding · 4 system design · 37 behavioral questions
Get their questions first.
InterviewLegend is independent and not affiliated with or endorsed by any company it covers.