InterviewLegend

Grids, Graphs & the In-Memory File System

Alex Chen35 min readGuide updated
In this lesson
  • Model an in-memory file system as a tree and find every path that carries a given name
  • Find the shortest path on a 0/1 grid with BFS, including a blocked start and start equal to target
  • Switch to Dijkstra or 0-1 BFS when the cost of a step depends on its direction
  • Talk through approach, pseudocode and complexity before you code, the way the round runs

Graphs and grids are the newest algorithm shapes in Disney's live coding. A Bengaluru Senior Product Engineer 1 loop in November 2026 opened its DSA round with an in-memory file system, built and searched with BFS and DFS. In September 2026 a Product Software Engineer II candidate in India got a grid shortest path with obstacles, where a step cost more or less depending on which way it went. The same grid with plain one-cost steps came up in 2025, at a phone screen and again at an onsite.

None of it is exotic. A senior on the Disney Experiences side said in March 2026 that the live round was one medium tree problem and one medium graph problem, and called both pretty easy. Disney engineers in 2026 put the coding bar at LeetCode easy to medium. So the points go to clean, working code and a clear explanation of it.

Java is the language in most recent Disney backend reports, so every solution below comes in Java first, with a Python version after it. Each problem runs in the editor with its own tests.

The Disney angle
Say the plan before you type. The September 2026 DSA round went from approach to pseudocode, complexity, code and then follow-ups, inside 60 minutes. The candidate finished the code and the follow-up talk in about 40. Expect to be stopped at each step and asked about edge cases and what you'd optimize.

How the Disney DSA round runs

The clearest example is a September 2026 Product Software Engineer II loop in India. Round one was a 60-minute DSA round on a grid shortest path. The discussion covered edge cases, time and space, and possible optimizations, and the candidate's advice afterwards was to know when BFS, Dijkstra or 0-1 BFS fits. That loop's other technical round was on .NET and C#, a reminder that the stack follows the team. For most backend roles it's Java.

The November 2026 Bengaluru loop put the file system first. A PR review with a US interviewer came next, then a hiring manager round and a behavioral round. The DSA round was a file system kept in memory as a graph, with paths built and searched by BFS and DFS, and file and folder names that repeat across directories.

The family also turns up without names. The March 2026 Disney Experiences senior loop had a medium tree problem and a medium graph problem. Back in 2022, a Disney Streaming frontend loop gave one candidate a DFS graph problem, while a friend interviewing for the same role got FizzBuzz.

Pick the traversal by what a step costs. When every step costs the same, BFS finds the shortest path, because it reaches cells in order of distance. When steps cost 0 or 1, a deque does the same job with free steps pushed to the front. Any other non-negative costs call for Dijkstra and a priority queue. A file system is a tree, so a plain BFS or DFS visits each node once.

In-memory file system with duplicate names

Something like this opened the Bengaluru Senior Product Engineer 1 loop in November 2026, as round one. The candidate described a graph-backed file system in memory, paths built and searched with BFS and DFS, and duplicate file and folder names. The class below keeps the operations of the classic in-memory file system and adds a search by name. Your interviewer's methods may differ, so practice the shape.

1

In-Memory File System With Duplicate Names

MediumSometimes asked
Problem
Build a FileSystem that lives in memory. It starts with only the root folder /, and every path is absolute, like /docs/notes.

Use mkdir(path) to create a folder and any missing parents. A call to write(path, content) creates a file, making parent folders as needed, and appends content if the file already exists. Reading with read(path) returns a file's content. Listing with ls(path) returns the sorted names inside a folder, or a one-item list with the file's own name when path is a file.

find(name) returns the full path of every file and folder whose own name equals name. The same name can sit in many folders, and a file and a folder can share it. Return shallower paths first and paths at the same depth in sorted order, comparing them folder by folder. Return an empty list when nothing matches.

You can assume every call is valid. read and ls only get paths that exist, and nothing writes to a folder's path.
  1. FileSystem()
  2. mkdir("/docs/notes")
  3. write("/work/notes", "draft")
  4. write("/docs/notes/notes", "todo")
  5. find("notes")→ ["/docs/notes","/work/notes","/docs/notes/notes"]
  6. ls("/work/notes")→ ["notes"]

notes is a folder under docs, a file under work, and a file inside that docs folder. All three come back, the two at depth two first.

How this uses the pattern

Store each folder as a sorted map from child name to child node. To search, run BFS from the root carrying each node's full path, and compare every child's own name with the target.

Write it here, or go full screen with the problem, hints and solution beside the editor.

In-Memory File System With Duplicate Names

Loading...
Click "Run" to execute your code
The Disney angle
Duplicate names are the catch in the Disney version. The tempting shortcut is a map from file name to path, filled in as files are written. It answers find in O(1) and breaks the first time notes exists in two folders, because the second entry overwrites the first. A tree of child maps keys every node by its parent and its name, which is exactly what a path means. Let the search build each path as it walks. Name the trade-off as you pick the traversal: BFS returns the shallowest matches first, while DFS holds only one branch in memory at a time.
Take it further
Search inside one folder, depth first. A natural next ask is a find limited to one folder, or matches listed in depth-first order. Resolve the folder with the same walk helper, then recurse into its children in sorted order, passing the path so far. Each subtree's matches then come out together. If links between folders get added, the tree becomes a graph that can loop, so keep a visited set of nodes.

Grid shortest path with obstacles

This one has the longest record of the three. In 2025 it came up in a Disney software engineer phone screen as a medium BFS problem, and again in an onsite next to a game leaderboard design. Both had a 0/1 grid, four-way moves and -1 when the target can't be reached. The follow-ups covered complexity, start equal to target, a blocked start or end, large grids and, as an option, diagonal moves. The September 2026 round built on the same grid, so get the plain version solid first.

2

Grid Shortest Path With Obstacles

MediumSignature problem
Problem
You get a grid of 0s and 1s, where 0 is an open cell and 1 is a wall, plus a start cell and a target cell given as [row, col]. Each step moves one cell up, down, left or right, onto an open cell inside the grid.

Return the fewest steps from start to target, or -1 if no path exists. If either cell is a wall, return -1. If they're the same open cell, the answer is 0.

Grids can be large, so keep the work linear in the number of cells.
Inputgrid = [[0,0,0],[1,1,0],[0,0,0]]start = [0,0]target = [2,0]Output6

The walls in the middle row force the path along the top, down the right side and back along the bottom.

How this uses the pattern

BFS from the start. Every step costs the same, so the first time BFS reaches the target it has used the fewest steps. Mark a cell as seen when you queue it.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Grid Shortest Path With Obstacles

Loading...
Click "Run" to execute your code
The Disney angle
The plain grid showed up at a 2025 phone screen and again onsite, and nearly every named follow-up is an edge case, so that's where the points are. Check the walls before the start-equals-target shortcut, or a walled start that equals the target returns 0. Mark a cell seen as you queue it. Marking on pop lets a large open grid queue the same cell several times. For large grids, keep one flat boolean array indexed by row * cols + col. The phone screen version ran from the top-left corner to the bottom-right, which is this problem with fixed corners.
Take it further
Diagonal moves. The optional extension lets a step go to any of the eight neighbors. Swap the four direction pairs for eight and BFS still works, since every step still costs one. Ask whether a diagonal step may slip between two walls that touch at a corner. The version below allows it. On very large grids, a BFS from both ends that stops where the two frontiers meet explores far fewer cells.

Grid path with direction costs

In September 2026 a Product Software Engineer II candidate in India got a 60-minute DSA round on a grid shortest path with obstacles, where moving cost different amounts depending on the direction. The skill being tested is knowing when BFS, Dijkstra or 0-1 BFS fits. Something like the problem below, with one price per direction, covers that ground. On LeetCode the closest match is problem 1368, a grid where following a cell's arrow is free and changing it costs 1, which is the 0-1 case.

3

Grid Path With Direction Costs

MediumCommonly asked
Problem
The grid works as before. 0 is an open cell, 1 is a wall, and each step moves up, down, left or right onto an open cell. This time each direction has a price. costs is [up, down, left, right], four non-negative integers, and a step in a direction costs that amount.

Return the cheapest total cost from start to target, or -1 when the target can't be reached or either cell is a wall. Staying where you are costs 0. The cheapest path may take more steps than the shortest one.
Inputgrid = [[0,0,0,1,0],[0,1,0,0,0],[0,0,1,1,0],[0,0,0,0,0]]start = [1,2]target = [3,0]costs = [5,1,1,1]Output8

The fewest-steps route climbs to the top row and costs 10 over 6 steps. Going right, down the far side and left along the bottom takes 8 steps and costs 8, since it never moves up.

How this uses the pattern

Run Dijkstra with a min-heap of (cost so far, row, col). Pop the cheapest cell, skip it if a cheaper cost is already recorded, and relax its four neighbors with the cost of that direction.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Grid Path With Direction Costs

Loading...
Click "Run" to execute your code
The Disney angle
Here BFS gives the wrong answer, and it's worth saying so before you write any code. BFS counts steps, and the first example shows the fewest steps costing more. Then pick the tool by the costs. Any non-negative costs need Dijkstra. If every cost is 0 or 1, a deque does it in linear time, which is the 0-1 BFS the candidate mentioned. The round went through pseudocode and complexity before any code, so have Dijkstra's O(V log V) on a grid ready, with V the number of cells and four edges each.
Take it further
Costs of only 0 and 1. When every cost is 0 or 1, swap the heap for a deque. Push a cell reached by a free step to the front and one reached by a paid step to the back. The deque stays in cost order, so each cell is handled in O(1) and the whole search is linear in the grid. With negative costs neither tool is safe, and that's worth one sentence if asked.

Disney coding interview questions

Does Disney ask LeetCode questions?

Yes, mostly at the easy to medium level. Disney engineers in 2026 said to expect LeetCode easy or medium, one panelist put frontend at easy at most, and one software engineer said they got no LeetCode at all. The named problems from 2025 and 2026 include graph and grid problems like these and an LRU cache. Teams set their own loops, so the mix depends on the org.

Which language should I use?

Java, if the role is backend and you're at home in it. It's named in the Spring Boot builds, the Java-only set problem and a live Java OOP round on HackerRank, all from 2025 or 2026. One 2026 India Product Software Engineer II loop was .NET and C# instead. Frontend roles code in JavaScript or TypeScript, and data roles in Python and SQL.

How long is the Disney DSA round?

In the September 2026 India loop it was booked for 60 minutes. The candidate went from approach to pseudocode, complexity, code and follow-ups, finished in about 40 minutes, and was done at about 45. For the rest of the loop, see The Disney Interview Process.

Key Takeaways

  • ✓Disney's newest named DSA problems are graphs and grids, from a file system searched with BFS and DFS to grid shortest paths.
  • ✓Key file system nodes by their parent folder and name. A map from name to path loses every duplicate.
  • ✓BFS counts steps. When steps have prices, use Dijkstra, or a 0-1 BFS deque when every price is 0 or 1.
  • ✓Talk through approach, pseudocode and complexity before you code. The September 2026 round followed that order.
Disney interview guide

Know what Disney asks before you walk in.

27 coding · 6 system design · 16 behavioral questions

Get Premium$49 a year · Instant access
Or start freeNo card.

Get their questions first.

What Disney TestsHad your Disney interview?How we research

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.