← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Meta SWE coding round, one question about finding the smallest positive integer made up entirely of odd digits. Pretty short session, nothing crazy.

Questions Asked (1)

Q1

Given an integer, find the smallest positive integer that is composed only of odd digits.

Algorithms & Data Structures
Author's notes

Took me a second to even parse what they were asking.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem first: given an integer N, find the smallest positive integer greater than N that consists only of odd digits (1,3,5,7,9). Then design a solution that either checks numbers sequentially or constructs the answer digit by digit, ensuring efficiency and correctness.

Pro tip: Always confirm whether the answer must be strictly greater than N or can be equal if N already has only odd digits. Also, discuss edge cases like N being very large or having trailing 9s, as these often trip up candidates.

1. Clarify requirements and constraints

Ask if the answer must be strictly greater than N, and confirm the definition of 'odd digits' (1,3,5,7,9). Discuss input size and expected time complexity.

2. Check if N itself qualifies

If N is positive and all its digits are odd, and the problem allows equality, return N. Otherwise, proceed to find the next number.

3. Choose an approach

Decide between brute-force increment and digit-by-digit construction. Brute-force is simple but may be slow for large gaps; construction is efficient but more complex.

4. Implement and handle edge cases

For brute-force, increment N until all digits are odd. For construction, build the smallest number greater than N using only odd digits, handling carries and digit replacements.

5. Test with examples and edge cases

Verify with cases like N=1 (answer 3 if strictly greater), N=9 (answer 11), N=100 (answer 111), and large numbers with many 9s.

Key Points to Mention

  • Definition of odd digits: only 1, 3, 5, 7, 9 are allowed.
  • The answer must be strictly greater than N (unless specified otherwise).
  • Brute-force approach: increment N and check each number's digits, O(k * d) where k is gap and d is digits.
  • Digit-by-digit construction: more efficient, O(d) time, by finding the first position to increase and filling the rest with the smallest odd digit (1).
  • Edge cases: N with all 9s (e.g., 999 -> 1111), N already having only odd digits (if equality allowed), and very large N.
  • Time and space complexity trade-offs between the two approaches.

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