String Parsing, Decoding And CLI Text Processing
Asked of: Software Engineer
Last updated
What's being tested
These problems test deterministic string parsing, careful boundary handling, and translating textual rules into simple state machines or lookup structures. You should demonstrate linear-time scans, explicit validation order, appropriate use of maps/stacks/recursion, and awareness of malformed input, case normalization, and combinatorial output size.
Patterns & templates
- Bijective base-26 conversion — repeatedly decrement before dividing by 26;
1→A,26→Z,27→AA;O(log₍₂₆₎ n)time and output space. - Flat-tree decoding — maintain a current node, consume each child index, emit at leaves, then reset to root; validate indices and incomplete final paths.
- Tokenization and validation — split once, verify token count and numeric fields, normalize case, then mutate state only after the entire command is valid.
- Sorted temporal scan — parse records into typed fields, use a moving time window or neighboring comparisons, and preserve required output order; avoid unnecessary
O(n²)pair checks. - Backtracking for wildcards — append each possible replacement, recurse, then undo;
O(2^k · L)output-sensitive time forkwildcards and lengthL. - Hash maps for ledger state — map normalized account names to balances; use wide integer types, reject overdrafts, and keep transfers atomic.
- Explicit edge-case contracts — define behavior for empty strings, zero values, duplicate records, negative numbers, trailing spaces, invalid indices, and wildcard-free inputs.
Common pitfalls
Pitfall: Treating spreadsheet labels as ordinary zero-based base 26 makes multiples of 26 produce incorrect
Zboundaries.
Pitfall: Updating balances while parsing a partially validated transaction can leave state corrupted when a later token or account check fails.
Pitfall: Assuming sorted input eliminates all transaction comparisons; a time-window rule may still require tracking every relevant prior city or record.
Practice these
The practice cards below cover the canonical variants — solve all of them and time yourself.
Practice questions
- Implement a simplified grep with case-insensitive, invert and exact-match flagsBloomberg · Software Engineer · Other · easy
- Implement an account balance tracker that parses deposit, withdraw and transfer transaction linesBloomberg · Software Engineer · Other · easy
- Decode a Message With an N-ary Prefix Code Tree of Child IndicesBloomberg · Software Engineer · Technical Screen · medium
- Convert Positive Column Numbers to Uppercase Letter TitlesBloomberg · Software Engineer · Other · easy
- Transactions Flagged by Amount or Cross-City TimingBloomberg · Software Engineer · Other · medium
- Solve Stack Decoding and Fuel-Constrained PathsBloomberg · Software Engineer · Technical Screen · hard
- Generate all strings by expanding wildcardsBloomberg · Software Engineer · Onsite · medium
- Find invalid transactions in time-sorted inputBloomberg · Software Engineer · Onsite · medium
- Implement a simplified grep with extensible flagsBloomberg · Software Engineer · Technical Screen · medium
- Solve two array and string problemsBloomberg · Software Engineer · Onsite · medium
Related concepts
- String Parsing, Palindromes, And NormalizationCoding & Algorithms
- String Parsing, Tokenization, And ValidationCoding & Algorithms
- String Processing, Parsing, And Output FormattingCoding & Algorithms
- Parsing, Expression Evaluation, And InterpretersSoftware Engineering Fundamentals
- Parsing, Serialization, And DeserializationCoding & Algorithms
- Parsing And Expression EvaluationCoding & Algorithms