FastPrepFile System Paths
Problems/File System Paths

File System Paths

Capital One logoCapital One● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A 2024 report from a Capital One software engineer candidate in Mexico City lists a single question: design a file system. The author calls it a known practice problem and gives nothing more. The process had a coding test and a final day of four interviews, and the report does not say which step asked it.

The report gives no operations, rules, input format, examples or limits, so the rest is our choice. Here every stored path holds a whole number, and the commands come as strings. CREATE works only for a new path whose parent is already stored, and a one-name path needs no parent. Missing parents are never made. A repeated CREATE is refused and keeps the first value, even when the value is the same. GET returns the stored value or -1. Each command adds one number to the answer, and CREATE adds 1 or 0. Paths are compared by whole names. The limits on commands, path length and values are also our choice.

Overall, our version is about 35% the same as the reported question.

Every stored path in this file system holds a whole number. A path is a chain of names, each with a / in front, such as /reports or /reports/summer/week. Dropping the last name gives the parent: /reports/summer is the parent of /reports/summer/week, while a one-name path like /reports has no parent. Names count as whole words, so /card is not the parent of /cards/gold.

commands holds two kinds of strings:

  • "CREATE path value": if path is new and its parent is stored (or it has no parent), save value there and add 1 to the answer. Otherwise add 0 and store nothing. A missing parent is never made for you, and a path that is already stored keeps its first value.
  • "GET path": add the value saved at exactly path, or -1 if nothing is saved there.

The file system is empty when commands begins. Return the numbers added by the commands, one per command, in the order the commands appear.

Function

runCommands(commands: String[]) → int[]

Examples

Example 1

commands = ["CREATE /photos 7","CREATE /photos/trips 41","CREATE /photos 99","GET /photos","GET /photos/trips/june"]return = [1,1,0,7,-1]

/photos has one name, so it needs no parent and is stored with 7. /photos/trips is stored because its parent /photos exists. The second CREATE /photos gives 0 because the path is already stored, and the value stays 7, as the GET shows. Nothing was ever stored at /photos/trips/june, so its GET gives -1.

Example 2

commands = ["CREATE /bank/loans/auto 300","CREATE /bank 5","CREATE /bank/loans/auto 300","GET /bank/loans/auto","CREATE /bank/loans 8","CREATE /bank/loans/auto 300","GET /bank/loans/auto"]return = [0,1,0,-1,1,1,300]

At first nothing is stored, so creating /bank/loans/auto fails. After /bank is stored, the same command still gives 0: its parent is /bank/loans, and an older ancestor does not count. Neither failure stored anything, so the first GET gives -1. Once /bank/loans exists, the third try succeeds and the last GET gives 300.

Example 3

commands = ["CREATE /card 2","CREATE /cards/gold 6","GET /cards","CREATE /card/gold 9","CREATE /card/gold 9","GET /card/gold"]return = [1,0,-1,1,0,9]

Paths are compared name by name, not letter by letter. /card is not the parent of /cards/gold, because cards and card are different names, so that command gives 0 and GET /cards gives -1. /card/gold does have /card as its parent and is stored with 9. Repeating that exact command gives 0, even with the same value.

Constraints

  • 1 <= commands.length <= 2000
  • Each command is CREATE path value or GET path, with one space between parts.
  • Every path is 2 to 60 characters long. It is one or more names, each with a single / in front, and each name is one or more lowercase letters from a to z. A path never ends with /.
  • Each value is an integer in the range 1 to 10^9, and its first digit is not 0.

More Capital One Onsite Interview questions

  • Digit-Coded Card ValidationONSITE INTERVIEW · Seen Nov 2026
  • Sort ColorsONSITE INTERVIEW · Seen Oct 2026
  • Virtual Card Transaction ValidatorONSITE INTERVIEW · Seen Oct 2026
  • Banking System with Top ActivityONSITE INTERVIEW · Seen Sep 2026
  • Transaction Event StoreONSITE INTERVIEW · Seen Jul 2026
  • Shortest Path in an Unweighted GraphONSITE INTERVIEW · Seen Jul 2026
  • Duplicate Transactions Within 60 SecondsONSITE INTERVIEW · Seen May 2026
  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen May 2026
  • Cashback TrackerONSITE INTERVIEW · Seen Nov 2025
  • Reverse a StringOA · ONSITE INTERVIEW · Seen Oct 2025

Similar questions at other companies

  • In-Memory Directory and File OperationsSquarepoint Capital · ONSITE INTERVIEWSquarepoint Capital interview questions
  • Design File SystemGoogle · PHONE SCREENGoogle interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • In-Memory Vault File SystemHarvey · ONSITE INTERVIEWHarvey interview questions
  • Word Dictionary with Wildcard FindAmazon · ONSITE INTERVIEW
  • Transform Dotted Keys into a Nested MapProofpoint · ONSITE INTERVIEW
  • Longest-Match Tokenizer with Unknown SymbolsAnthropic · ONSITE INTERVIEWAnthropic interview questions
  • Implement uniq: Unique LinesVanta · ONSITE INTERVIEW
  • Implement a TrieMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Text Embedding and Vector SearchNike, Inc. · PHONE SCREEN · ONSITE INTERVIEWNike, Inc. interview questions

Capital One interview experiences

  • Capital One Experienced Engineer Power Day and OA: 6 Experiences
  • Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
  • Capital One TDP Agentic Round (AI Coding): 7 Experiences
  • Capital One SWE Power Day, Level Not Reported: 6 Experiences
  • Capital One TIP Intern OA and Power Day: 13 Experiences
  • Capital One TDP Agentic Power Day: 25 Experiences (Part 1 of 2)
All Capital One interview questionsSee Capital One hiring insights
Saved
class Solution {
    public int[] runCommands(String[] commands) {
        // Write your code here.
    }
}
Checking account…