← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Meta coding screen with a digit-counting problem that looks easy but has a few edge cases worth thinking through carefully.

Questions Asked (1)

Q1

Given two integers left and right (both three-digit numbers, 100 to 999), count how many integers in the range [left, right] have all three digits distinct from each other.

Algorithms & Data Structures
Author's notes

Looks trivial at first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem and constraints, then discuss a brute-force solution that checks each number in the range by extracting and comparing its digits. Optimize by either precomputing valid numbers or using combinatorics to count directly, and analyze time and space complexity.

Pro tip: Mention that since the range is at most 900 numbers, brute force is acceptable, but demonstrating an O(1) combinatorial solution shows deeper insight. Also, handle edge cases like when left > right or when the range includes numbers with leading zeros (though not applicable here).

1. Understand the problem

Restate the problem in your own words and confirm constraints: left and right are three-digit numbers, and we need to count numbers with all distinct digits.

2. Discuss brute force

Explain a simple approach: iterate from left to right, for each number extract its hundreds, tens, and units digits, and check if all three are distinct. Count the valid ones.

3. Analyze complexity

State that the brute force runs in O(n) time where n = right - left + 1 (at most 900), and O(1) space. This is efficient enough for the given constraints.

4. Optimize (optional)

If asked for optimization, propose a combinatorial approach: count valid numbers up to a given number using digit DP or precomputed counts, then answer queries in O(1).

5. Test with examples

Walk through a small example, e.g., left=100, right=120, and verify the count. Also consider edge cases like left=right or ranges with no valid numbers.

Key Points to Mention

  • Digit extraction using modulo and division
  • Time and space complexity analysis
  • Edge cases: left > right, single number range, numbers with repeated digits
  • Alternative combinatorial or digit DP approach for O(1) per query
  • Handling of three-digit numbers only (no leading zeros)
  • Clarifying questions: inclusive range? input validation?

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