The Letter Tally
A easy Python mock interview question on DataDriven. Practice with AI-powered feedback, real code execution, and a hire/no-hire decision.
- Domain
- Python
- Difficulty
- easy
- Seniority
- L3
Interview Prompt
Implement a CharCounter class whose constructor takes a string `text`, and provide a top-level driver function `char_counter_demo(text)` that constructs CharCounter(text) and returns the result of its `get_counts()` method. `get_counts()` returns a list of `[char, count]` pairs (each pair a two-element list), one per distinct character, sorted alphabetically by character (standard codepoint order, so uppercase letters sort before lowercase). Ignore spaces and punctuation: count only alphanumeric characters. Counting is case-sensitive, so 'A' and 'a' are distinct. For a string with no alphanumeric characters, return an empty list.
Summary
Each character in the string has a count to answer for.
How This Interview Works
- Read the vague prompt (just like a real interview)
- Ask clarifying questions to the AI interviewer
- Write your python solution with real code execution
- Get instant feedback and a hire/no-hire decision