Fastest Route Across a Map Grid With Flash on Cooldown

Last updated: November 29, 2026

Quick Overview

On a grid of open cells and walls, a champion moves one cell per tick in four directions, or can Flash up to k cells in any of eight directions over walls if Flash is off cooldown, which then puts it on a c-tick cooldown. Return the minimum ticks from start to goal, or -1.

Riot Games
Coding & Algorithms
Software Engineer
Riot Games
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


On a grid of open cells and walls, a champion moves one cell per tick in four directions, or can Flash up to k cells in any of eight directions over walls if Flash is off cooldown, which then puts it on a c-tick cooldown. Return the minimum ticks from start to goal, or -1.

A harder onsite graph question themed on Summoner's Rift pathing and summoner spells, relevant to gameplay and bot AI engineers. The interviewer looks for the insight that cooldown must be part of the BFS state, a correct state space bound, and clean handling of Flash landing rules.

What the Interviewer Expects
  • Recognize that position alone is not a sufficient state
  • Model state as (row, col, cooldown remaining)
  • Use BFS since every action costs one tick
  • Allow Flash to pass over walls but only land on open cells
  • Bound complexity by R x C x (c + 1) states times branching
  • Explain why Dijkstra is unnecessary here but needed if costs differed
Key Topics to Cover
BFS
state space search
graphs
game AI
pathfinding
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you change the solution if Flash took zero ticks?
  • How would you add a second summoner spell like Ghost that doubles speed for a few ticks?
  • How could A* with an admissible heuristic speed this up on a large map?
  • How would bot AI reuse this to decide whether Flash is worth burning?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Grid cells are . or #. Each tick you either walk one cell (4 directions, open cells only) or, if cooldown is 0, Flash 1 to k cells straight in one of 8 directions, landing on an open cell even if ...

High-Level Design

A plain BFS on cells is wrong: reaching a cell with Flash ready is strictly better than reaching it with Flash on cooldown, so the two must be different nodes. State is (r, c, cd) with cd in `0..c...


Submit Your Answer
Markdown supported

Related Questions