← Oracle Interview Insights

Oracle·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Oracle SWE interview with a string decoding problem that looks manageable until you actually sit down and think through all the edge cases. Single coding question, parsing-heavy, and the O(1) space constraint is what makes it interesting.

Questions Asked (1)

Q1

You're given a specially encoded string where letters a-i map to digits 1-9, letters j-z map to two digits followed by a '#', and consecutive repeated characters are compressed with a count in parentheses. Write a function that decodes the string and returns an array of 26 integers representing how many times each letter appears.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The encoding rules themselves aren't hard to follow but parsing everything in one pass without building the decoded string is where I got tripped up.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the encoding rules and edge cases, then design a single-pass parser that handles digit mappings, '#' delimiters, and repeat counts. Use a frequency array of size 26 and update counts as you decode each character, ensuring O(n) time and O(1) extra space.

Pro tip: Mention that you would validate the input and handle malformed strings gracefully, and discuss how the solution scales for large inputs—this shows production-level thinking beyond just solving the puzzle.

1. Clarify the encoding rules

Confirm the mapping: 'a'-'i' to '1'-'9', 'j'-'z' to two digits followed by '#', and repetition via parentheses. Ask about edge cases like multi-digit counts, invalid input, and whether the output should be an array of 26 integers.

2. Design the parsing strategy

Plan a single left-to-right scan: when you see a digit 1-9, check if it's followed by '#' to decide if it's a single-letter code or part of a two-digit code. When you see '(', parse the number until ')' to get the repeat count.

3. Implement the decoder

Use a frequency array of size 26. For each decoded letter, increment its count by the repeat multiplier (default 1). Handle the two-digit codes by reading two digits and the '#'.

4. Test with examples and edge cases

Walk through examples like '1(2)23#(3)' to verify correctness. Test edge cases: single character, large repeat counts, codes at the end of string, and invalid sequences.

5. Analyze complexity and trade-offs

State that the solution is O(n) time and O(1) space (since the frequency array is fixed size). Discuss alternative approaches like regex or two-pass parsing and why single-pass is better.

Key Points to Mention

  • Single-pass parsing with O(n) time complexity
  • Constant space using a fixed-size frequency array
  • Handling of two-digit codes with '#' delimiter
  • Parsing repeat counts in parentheses, including multi-digit numbers
  • Edge cases: empty string, invalid input, large repeat counts
  • Trade-offs between clarity and performance (e.g., regex vs manual parsing)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.