← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Meta SWE coding screen, one question about filtering and reconstructing digits from an integer. Pretty short session, nothing too wild.

Questions Asked (1)

Q1

Given an integer, return the smallest nonnegative integer that can be formed using only its odd digits. If none of the digits are odd, return None. For example, 62315 becomes 135, 260 returns None, and -25 returns 5.

Algorithms & Data Structures
Author's notes

The negative number case tripped me up briefly.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify edge cases and constraints (e.g., negative numbers, zero, leading zeros). Then, extract all odd digits, sort them in ascending order, and construct the smallest number by placing the smallest non-zero digit first followed by the remaining digits in ascending order. If no odd digits exist, return None.

Pro tip: Mention that you handle negative numbers by taking the absolute value, and that leading zeros are avoided by placing the smallest non-zero odd digit first. Also, discuss the time complexity (O(d log d) where d is the number of digits) and potential optimizations like counting sort for digits.

1. Clarify requirements and edge cases

Ask about input range, negative numbers, zero, and whether leading zeros are allowed. Confirm that the output should be an integer, not a string.

2. Extract odd digits

Iterate through the absolute value of the number and collect all digits that are odd (1,3,5,7,9).

3. Sort digits and handle leading zeros

Sort the collected digits in ascending order. If the smallest digit is 0, find the smallest non-zero digit and swap it with the first zero to avoid leading zeros.

4. Construct the smallest number

Combine the sorted digits into an integer. If no odd digits were found, return None.

5. Test with examples and edge cases

Verify with provided examples (62315 -> 135, 260 -> None, -25 -> 5) and additional cases like 0, -100, 111, etc.

Key Points to Mention

  • Handling negative numbers by taking absolute value
  • Ignoring even digits and zero (since zero is even)
  • Sorting digits to get smallest number
  • Avoiding leading zeros by placing smallest non-zero odd digit first
  • Returning None when no odd digits exist
  • Time and space complexity analysis

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