Solve Signature, File, and Queue Problems
ConfluentSoftware Engineer · OnsiteLast updated
This multi-part prompt evaluates skills in function signature and type matching, resource-constrained file I/O and streaming for large files, and data-structure design for randomized queues including multiset equality, synchronization, and compact run-length encodings.
Solve the following interview-style problems:
-
Function signature matching You are given a registry of function definitions. Each function has an ordered parameter list where parameters may be required, optional, or a trailing variadic parameter. Given a candidate call signature represented as an ordered list of argument types, determine whether at least one registered function can accept the call. Assume exact type matching and no implicit coercions.
-
Print the last N lines of a large file Implement a utility that prints the last
Nlines of a file tostdout. The file may be much larger than memory, so the solution should avoid loading the entire file. Discuss tradeoffs between scanning with fixed-size buffers versus seeking backward with file offsets. Then write pseudocode using only the following file API:
size() -> intread(k) -> bytesfrom the current file pointer, advancing the pointermove(delta)to shift the file pointer forward or backward bydeltabytes
The final output must be streamed to stdout rather than first materializing the full answer in memory.
- Random queue Design a queue-like data structure that supports insertion but returns or removes a uniformly random existing element instead of the oldest element. Then discuss:
- how to determine whether two such queues are equal,
- what synchronization and correctness issues arise in a multithreaded implementation,
- and how equality checking changes if the queue contents are stored using variable-length run-length encoding.
Assume equality means the two queues represent the same multiset of values, regardless of internal storage layout.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.