PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Robinhood

Design a constrained cache and secure string validator

Last updated: Apr 26, 2026

Quick Overview

This question evaluates proficiency in data structures and algorithms (constrained cache design), concurrent programming, complexity analysis, and secure input parsing for address classification, with emphasis on robustness, failure modes, and security-aware validation.

  • medium
  • Robinhood
  • Coding & Algorithms
  • Software Engineer

Design a constrained cache and secure string validator

Company: Robinhood

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

## Part A — Constrained cache (LRU-like) Design an in-memory cache that supports the following operations: - `get(key) -> value | null` - `put(key, value) -> void` ### Functional requirements - The cache has a fixed capacity `C` (number of entries). When inserting into a full cache, evict an entry based on a well-defined policy (e.g., least-recently-used). - `get` and `put` should be efficient (target amortized \(O(1)\)). ### Security/robustness requirements (discuss + implement) - **High concurrency:** multiple threads may call `get/put` concurrently. Describe and/or implement a thread-safe approach. - **Abuse scenarios:** discuss how the cache behaves under: - extremely hot keys (contention), - key-spamming (many unique keys), - intentionally malformed/oversized keys or values. - **Failure handling:** define behavior for null/empty keys, capacity \(C \le 0\), memory pressure, and unexpected exceptions. ## Part B — Secure string validation (IP-like) Write a function `classifyAddress(s: string) -> "IPv4" | "IPv6" | "Neither"`. ### Core rules (typical IPv4/IPv6 validation) - IPv4: four decimal segments separated by `.`, each `0..255`, no leading `+/-`, no extra spaces; handle leading zeros per your chosen policy but state it clearly. - IPv6: eight hex segments separated by `:`, each `1..4` hex chars (`0-9`, `a-f`, `A-F`). ### Security constraints (must address) - **Bypass resistance:** your parser must not accept inputs that can trick naive implementations (e.g., hidden whitespace, mixed separators, Unicode lookalikes, overflow like `9999999999`, empty segments, trailing separators). - **Performance under abnormal traffic:** avoid worst-case blowups (e.g., pathological long strings). State time and space complexity and any length limits you enforce. Return the classification string for each input.

Quick Answer: This question evaluates proficiency in data structures and algorithms (constrained cache design), concurrent programming, complexity analysis, and secure input parsing for address classification, with emphasis on robustness, failure modes, and security-aware validation.

Related Interview Questions

  • Build a Weekly Calendar - Robinhood (medium)
  • Solve path and inventory problems - Robinhood
  • Implement Calendar Layout and String Packing - Robinhood (medium)
  • Aggregate user logs into 30-minute sessions - Robinhood (hard)
  • Count Referral Descendants - Robinhood (medium)
Robinhood logo
Robinhood
Jan 22, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
3
0
Loading...

Part A — Constrained cache (LRU-like)

Design an in-memory cache that supports the following operations:

  • get(key) -> value | null
  • put(key, value) -> void

Functional requirements

  • The cache has a fixed capacity C (number of entries). When inserting into a full cache, evict an entry based on a well-defined policy (e.g., least-recently-used).
  • get and put should be efficient (target amortized O(1)O(1)O(1) ).

Security/robustness requirements (discuss + implement)

  • High concurrency: multiple threads may call get/put concurrently. Describe and/or implement a thread-safe approach.
  • Abuse scenarios: discuss how the cache behaves under:
    • extremely hot keys (contention),
    • key-spamming (many unique keys),
    • intentionally malformed/oversized keys or values.
  • Failure handling: define behavior for null/empty keys, capacity C≤0C \le 0C≤0 , memory pressure, and unexpected exceptions.

Part B — Secure string validation (IP-like)

Write a function classifyAddress(s: string) -> "IPv4" | "IPv6" | "Neither".

Core rules (typical IPv4/IPv6 validation)

  • IPv4: four decimal segments separated by . , each 0..255 , no leading +/- , no extra spaces; handle leading zeros per your chosen policy but state it clearly.
  • IPv6: eight hex segments separated by : , each 1..4 hex chars ( 0-9 , a-f , A-F ).

Security constraints (must address)

  • Bypass resistance: your parser must not accept inputs that can trick naive implementations (e.g., hidden whitespace, mixed separators, Unicode lookalikes, overflow like 9999999999 , empty segments, trailing separators).
  • Performance under abnormal traffic: avoid worst-case blowups (e.g., pathological long strings). State time and space complexity and any length limits you enforce.

Return the classification string for each input.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Robinhood•More Software Engineer•Robinhood Software Engineer•Robinhood Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

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

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • 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.