← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Meta SWE coding round, one problem about counting three-digit numbers with distinct digits in a given range. Pretty focused session, nothing wild.

Questions Asked (1)

Q1

Given a range [left, right] where both bounds are three-digit numbers, count how many integers in that range have all three digits distinct from each other.

Algorithms & Data Structures
Author's notes

Seemed straightforward at first, just iterate and check each number.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify that the range bounds are inclusive and that we need to count numbers with three distinct digits. Then either iterate through the range and check each number's digits for uniqueness, or use a combinatorial counting approach to compute the count directly. Discuss trade-offs between the two methods based on range size and constraints.

Pro tip: Mention that a brute-force check is O(n) and fine for small ranges, but if the range is large or the function is called repeatedly, a precomputed prefix sum array of valid counts up to 999 allows O(1) queries. This shows you think about scalability and real-world usage.

1. Clarify requirements and edge cases

Confirm that the range is inclusive, both bounds are three-digit numbers (100-999), and that numbers like 100 (digits 1,0,0) do not qualify. Ask if the range can be large or if multiple queries are expected.

2. Choose an approach

Decide between a simple iteration with digit extraction and a combinatorial counting method. For a single query, iteration is straightforward; for multiple queries, precompute a prefix sum array.

3. Implement digit uniqueness check

For a given number, extract its hundreds, tens, and ones digits using division and modulo. Check that all three are distinct (e.g., h != t && h != o && t != o).

4. Count valid numbers in range

If iterating, loop from left to right, apply the check, and increment a counter. If using precomputation, build an array where prefix[i] = count of valid numbers from 100 to i, then answer = prefix[right] - prefix[left-1].

5. Analyze complexity and optimize

State the time complexity: O(n) for iteration where n = right - left + 1, or O(1) per query after O(900) precomputation. Discuss space trade-offs and when each method is preferable.

Key Points to Mention

  • Inclusive range and three-digit constraint (100 to 999)
  • Digit extraction using division and modulo
  • Condition for distinct digits: h != t && h != o && t != o
  • Brute-force iteration vs. combinatorial counting or precomputation
  • Time and space complexity analysis
  • Handling multiple queries efficiently with prefix sums

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