← Google Interview Insights

Google·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jul 2026

Summary

Google coding screen, one question the whole time. Seemed straightforward on the surface but the edge cases kept piling up and I left feeling like I'd only half-solved it.

Questions Asked (1)

Q1

Given an integer (which may be negative), write a function that returns its string representation with commas inserted as thousands separators every three digits from the right. For example, 1234567 should become '1,234,567'. You cannot use any built-in number formatting utilities.

Algorithms & Data Structures
Author's notes

I started by converting the number to a string and working backwards, which felt right, but then the negative sign threw me off and I fumbled around for a bit trying to handle it cleanly.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem constraints and edge cases first, then propose a simple algorithm that processes the digits from right to left, inserting commas every three digits. Write clean code with clear variable names, and test with positive, negative, and zero inputs.

Pro tip: Mention that you would handle the sign separately and consider using a StringBuilder for efficiency, but avoid over-engineering. Also, discuss potential edge cases like zero and negative numbers to show thoroughness.

1. Clarify requirements and edge cases

Ask about input range, negative numbers, zero, and whether the output should include a sign. Confirm that no built-in formatting is allowed.

2. Outline the algorithm

Explain that you will convert the absolute value to a string, then iterate from the end, inserting commas every three digits. Handle the sign separately.

3. Implement the solution

Write code that builds the result string, ensuring commas are placed correctly. Use a loop or string manipulation without built-in formatting.

4. Test with examples

Walk through test cases: 1234567 -> '1,234,567', -1234567 -> '-1,234,567', 0 -> '0', 1000 -> '1,000', 999 -> '999'.

5. Analyze complexity and discuss optimizations

State time and space complexity (O(n) where n is number of digits). Mention potential optimizations like using a StringBuilder or pre-allocating space.

Key Points to Mention

  • Handling negative numbers by extracting the sign and processing the absolute value.
  • Edge cases: zero, numbers with fewer than four digits, and very large numbers.
  • Algorithm: iterate from the end of the string, inserting a comma every three digits.
  • Avoiding built-in formatting utilities like toLocaleString or Intl.NumberFormat.
  • Time and space complexity: O(n) time and O(n) space for the output string.
  • Testing strategy: include positive, negative, zero, and boundary cases.

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