← Intuit Interview Insights

Intuit·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jul 2026

Summary

Interviewed at Intuit for a software engineering role and got a string parsing problem that looked straightforward but had a few gotchas buried in the details.

Questions Asked (1)

Q1

Given a multiline string representing the output of 'ls -l', parse each line to extract the file size and the filename, then return the filename with the largest file size. Note that filenames can contain spaces.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The spaces-in-filename part is what gets you.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the exact format of the 'ls -l' output and edge cases like filenames with spaces and symbolic links. Then, outline a parsing strategy that splits each line into fields, extracts the size and filename, and tracks the maximum. Finally, discuss trade-offs such as handling large inputs and potential ambiguities.

Pro tip: Mention that you would use a regular expression or split with a limit to handle filenames with spaces, and explicitly state how you'd handle symbolic links (e.g., using the target size or skipping them). This shows attention to real-world details.

1. Clarify the input format

Ask or state assumptions about the 'ls -l' output: typical fields include permissions, links, owner, group, size, date, and filename. Confirm that filenames can contain spaces and that the size is the 5th field.

2. Design the parsing logic

For each line, split into at most 9 parts (since there are 8 fields before the filename) or use a regex to capture the size and the rest as filename. Ensure the filename preserves spaces.

3. Track the maximum

Initialize variables to store the largest size and corresponding filename. For each parsed line, compare the size (as integer) and update if larger.

4. Handle edge cases

Consider lines that are not regular files (e.g., directories, symbolic links) and decide whether to include them. Also handle empty lines or malformed input gracefully.

5. Return the result

After processing all lines, return the filename with the largest size. If no valid lines, return null or an appropriate message.

Key Points to Mention

  • Use of split with maxsplit parameter or regex to correctly parse filenames with spaces.
  • Time complexity: O(n) where n is number of lines, and space complexity O(1) beyond input.
  • Handling of symbolic links: whether to use the link's size or the target's size, and how 'ls -l' displays it.
  • Edge cases: empty input, lines with different formats, very large files (integer overflow considerations).
  • Trade-offs between regex and manual splitting in terms of readability and performance.
  • Assumption that the size field is always the 5th field in a standard 'ls -l' output.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.