Roblox software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
RequestRateDetector class. configure(limit: int, window: int) -...Input: Number(s)tasks of length n and an integer...Input: ArrayBackground
Requirements
disk_load and cdn_load. Each accepts an asset ID and returns immutable, nonempty bytes or None when unavailable. On a cache miss, consult disk first and consult the CDN only if disk returns None. Do not write CDN results back to disk.acquire(asset_id) returns the asset's bytes and adds one active reference. A cache hit does not invoke either callback and makes the asset most recently used. A successful cache insertion starts with one reference and is also most recently used. An entry with at least one reference is pinned and cannot be evicted.None without changing cache contents, reference counts, or order. Once disk returns bytes, do not try the CDN even if those bytes cannot be admitted.release(asset_id) removes exactly one active reference and returns True; return False if the asset is absent or already has zero references. Releasing an asset does not change its recency or immediately evict it. invalidate(asset_id) removes an unpinned cached asset and returns True; return False for an absent or pinned asset.None and is not negatively cached. Callback exceptions propagate, leaving the cache unchanged. snapshot() returns (asset_id, byte_size, reference_count) tuples in least-to-most-recently-acquired order, without changing state. All failure paths must preserve the same ordering as well as the same contents.Class API
AssetResourceLoader(capacity_bytes: int, disk_load: Callable[[str], bytes | None], cdn_load: Callable[[str], bytes | None]) — construct an empty loader; reject nonpositive capacity with ValueError.acquire(asset_id: str) -> bytes | None — acquire one reference to an available, admissible asset.release(asset_id: str) -> bool — release one reference without changing recency.invalidate(asset_id: str) -> bool — remove an entry only when it is unpinned.snapshot() -> list[tuple[str, int, int]] — return a detached view of cached entries in eviction order.Example 1
10 bytes. The disk fixture contains mesh:A = b"AAAA" and texture:B = b"BBBB". The CDN fixture contains audio:C = b"CCCCCC". Missing fixture keys return None.Input sequenceacquire("mesh:A")
acquire("texture:B")
release("mesh:A")
acquire("audio:C")
snapshot()
invalidate("texture:B")
release("texture:B")
invalidate("texture:B")
snapshot()Output, one result per callb"AAAA"
b"BBBB"
True
b"CCCCCC"
[("texture:B", 4, 1), ("audio:C", 6, 1)]
False
True
True
[("audio:C", 6, 1)]Explanation: Initially, the cache uses 4 + 4 = 8 bytes. Loading the six-byte audio asset requires reclaiming four bytes. mesh:A is unpinned and oldest, so evicting it leaves 4 + 6 = 10 bytes. texture:B cannot be invalidated until its active reference is released.Example 2
8 bytes. Disk contains mesh:A = b"AAAA" and texture:B = b"BBBB". CDN contains audio:C = b"CCCCCC".Input sequenceacquire("mesh:A")
acquire("texture:B")
release("mesh:A")
acquire("audio:C")
snapshot()
release("texture:B")
acquire("audio:C")
snapshot()Output, one result per callb"AAAA"
b"BBBB"
True
None
[("mesh:A", 4, 0), ("texture:B", 4, 1)]
True
b"CCCCCC"
[("audio:C", 6, 1)]Explanation: The first audio acquisition needs six bytes reclaimed because 8 + 6 - 8 = 6. Only four bytes are unpinned, so admission fails without evicting mesh:A. After releasing texture:B, both four-byte entries are eligible. The second attempt loads the audio again and evicts both entries, leaving six cached bytes.Constraints
1 <= capacity_bytes <= 10^9; at most 10^5 method calls and 10^5 distinct asset IDs.1 through 10^9.O(1) cache hits, releases, and invalidations; cache-miss admission may scan cached entries.Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free