PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCareers

Quick Overview

This combined prompt evaluates string-processing and parsing skills for tag matching and design/implementation skills for an in-memory file system, measuring competencies in exact whole-word matching, case normalization, punctuation and duplicate handling, path parsing, hierarchical data structures, and file API behaviors.

  • medium
  • Harvey
  • Coding & Algorithms
  • Backend Engineer

Implement tag matcher and filesystem

Company: Harvey

Role: Backend Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

This interview reportedly included two coding problems: 1. **Tag matching in text** Given a sentence and a list of tags or keywords, return the tags that appear in the sentence as **whole-word matches**. Matching may be treated as case-insensitive, but partial-word matches do **not** count. For example, if the sentence contains `blueprint`, the tag `blue` must **not** be considered a match. Be prepared to clarify how punctuation, duplicates, and output ordering should be handled. 2. **In-memory file system** Design and implement an in-memory file system that supports common operations such as: - creating directories, - listing directory contents, - writing file contents, - reading file contents. Be prepared to discuss path parsing, internal data structures, and edge cases such as nested directories, creating missing parents, and appending to an existing file.

Quick Answer: This combined prompt evaluates string-processing and parsing skills for tag matching and design/implementation skills for an in-memory file system, measuring competencies in exact whole-word matching, case normalization, punctuation and duplicate handling, path parsing, hierarchical data structures, and file API behaviors.

Part 1: Whole-Word Tag Matching in Text

Given a sentence and a list of candidate tags, return the tags that appear in the sentence as whole words. Matching is case-insensitive. A whole word is a maximal sequence of letters and digits, so any non-alphanumeric character in the sentence acts as a separator. Partial matches do not count: for example, the tag 'blue' does not match inside 'blueprint'. The output must contain each matching tag at most once, preserve the order of first appearance in the input tag list, and if the same tag appears multiple times with different casing, only the first occurrence should be considered.

Constraints

  • 0 <= len(sentence) <= 100000
  • 0 <= len(tags) <= 10000
  • Each tag is non-empty and contains only letters and digits
  • Matching is case-insensitive
  • Any non-alphanumeric character in the sentence is treated as a separator

Examples

Input: ('The blue car is parked near the red-house.', ['blue', 'red', 'green'])

Expected Output: ['blue', 'red']

Explanation: Hyphen is treated as a separator, so both 'blue' and 'red' are whole-word matches.

Input: ('The blueprint was approved.', ['blue', 'print', 'blueprint'])

Expected Output: ['blueprint']

Explanation: Neither 'blue' nor 'print' appears as a whole word; only 'blueprint' does.

Input: ('Blue, blue; RED!', ['red', 'Blue', 'blue', 'green', 'RED'])

Expected Output: ['red', 'Blue']

Explanation: Matching is case-insensitive, and duplicate tags are returned only once based on their first appearance in the tag list.

Input: ('', ['a', 'b'])

Expected Output: []

Explanation: Edge case: an empty sentence contains no words.

Hints

  1. Convert the sentence into a set of normalized whole words first, so each lookup is fast.
  2. Be careful to remove duplicate tags by their lowercase form while still preserving the first original spelling from the input list.

Part 2: Simulate an In-Memory File System

Implement an in-memory file system simulator. The file system starts with only the root directory '/'. You must process a sequence of operations: 'mkdir', 'ls', 'addContentToFile', and 'readContentFromFile'. Paths are absolute. 'mkdir' creates the target directory and any missing parent directories. 'addContentToFile' creates missing parent directories if needed, creates the file if it does not exist, and appends to the file if it already exists. 'ls' returns the lexicographically sorted names of the immediate children of a directory, or [file_name] if the path points to a file. 'readContentFromFile' returns the full file contents.

Constraints

  • 1 <= len(operations) <= 20000
  • len(operations) == len(arguments)
  • All paths are absolute and valid
  • Path components do not contain '/'
  • There are no conflicts where the same path must be both a file and a directory

Examples

Input: (['mkdir', 'addContentToFile', 'ls', 'readContentFromFile'], [('/a/b',), ('/a/b/file.txt', 'hello'), ('/a/b',), ('/a/b/file.txt',)])

Expected Output: [None, None, ['file.txt'], 'hello']

Explanation: Both directory creation and file writing succeed, and the missing parent directories for the file already exist.

Input: (['addContentToFile', 'addContentToFile', 'readContentFromFile', 'ls'], [('/notes.txt', 'hi'), ('/notes.txt', ' there'), ('/notes.txt',), ('/',)])

Expected Output: [None, None, 'hi there', ['notes.txt']]

Explanation: Writing to an existing file appends content instead of overwriting it.

Input: (['mkdir', 'addContentToFile', 'addContentToFile', 'ls', 'ls'], [('/z/y',), ('/z/a.txt', '1'), ('/z/b.txt', '2'), ('/z',), ('/z/a.txt',)])

Expected Output: [None, None, None, ['a.txt', 'b.txt', 'y'], ['a.txt']]

Explanation: Directory listings are sorted, and listing a file path returns a single-element list with the file name.

Input: (['ls'], [('/',)])

Expected Output: [[]]

Explanation: Edge case: listing the empty root directory returns an empty list.

Hints

  1. A tree structure works well: each directory stores its children, and file nodes store content.
  2. Split each path by '/' and ignore empty parts so that '/' is handled cleanly.
Last updated: May 10, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • Careers
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Evaluate Symbol Expressions - Harvey (medium)
  • Implement a Cursor-Based Text Editor - Harvey (medium)
  • Highlight Exact Source Matches - Harvey (medium)
  • Design Spreadsheet Formula Cells - Harvey (medium)
  • Implement retrieval and evaluation for a simple RAG - Harvey (medium)