AI & Technical question
Write a code to increment an array of digits (0 to 9).
- AI & Technical
- Hard
Practice this question out loud. An AI interviewer asks it, follows up like a real interviewer would, and scores your answer. Type or speak.
Start a mock interview on this question · Mock interview from a job description
What this question tests
Tests basic coding fluency expected of a technical PM: writing a correct, simple algorithm and explaining edge cases in plain terms.
How to approach it
- Clarify the input: an array of digits representing a number, most significant digit first, and the output should be the array after adding one.
- Walk through the logic: start from the last digit, add one, and if it is less than 10, return immediately since no carry is needed.
- Handle the carry case: if a digit becomes 10, set it to 0 and carry one to the digit before it, repeating leftward.
- Handle the edge case: if every digit carries (all 9s, like 999), the array grows by one digit with a leading 1.
- Write the code in simple pseudocode or a language like Python, iterating from the end of the array.
What a strong answer includes
- Handles the carry-propagation case correctly, since a naive solution that only increments the last digit fails on inputs like 9 or 99.
- Explicitly calls out the all-9s edge case (999 becomes 1000), which requires growing the array, a common trap in this exact problem.
- Explains the logic in plain language before or alongside the code, which matters for a PM-level technical assessment.
- Keeps the solution simple and iterative rather than overcomplicating with unnecessary recursion or libraries.
Common mistakes
- Forgetting the carry case entirely and only incrementing the last digit.
- Missing the edge case where all digits are 9 and the array needs to grow by one element.
Likely follow-up questions
- How would you modify this if the array could also represent a negative number?
- What is the time complexity of your solution, and can it be improved?
More ai & technical questions
- Design a simple load balancer for Google.com. What data structures would you use?Google · AI & Technical · Hard
- How does TinyURL work?Google · AI & Technical · Easy
- How would you explain cloud computing to your grandmother?Google · AI & Technical · Easy
- What happens when you enter a URL in your browser?Google · AI & Technical · Easy
- You’re part of the Google Search web spam team. How would you detect duplicate websites?Google · AI & Technical · Hard
- Explain the data pipeline for the last AI project you worked on. What were the top challenges in getting data, and how did you resolve them?Google · AI & Technical · Hard
More questions from Google
Learn the skill behind it
Chapters of the AI PM course that teach what this question tests.
- Chapter 1: Foundations: the model and the decisions it forces on you
- Chapter 8: Evals: define good and make the number defensible
- Chapter 6: Agents and agentic architecture