← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Meta SWE coding screen, basically one binary search problem on a sorted array with duplicates. Pretty standard stuff but the edge cases are where they actually want to see you think.

Questions Asked (1)

Q1

Given a sorted integer array that may contain duplicates and a target value, return any valid index of the target in O(log n) time, or -1 if it doesn't exist.

Algorithms & Data Structures
Author's notes

Classic binary search but the duplicates thing is a small wrinkle.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use binary search to find any occurrence of the target in O(log n) time. Since the array is sorted and may contain duplicates, a standard binary search that returns when the target is found is sufficient; no need to find the first or last occurrence. Clearly state the algorithm, walk through an example, and analyze time and space complexity.

Pro tip: Mention that while duplicates don't affect the O(log n) guarantee for finding any index, if the interviewer later asks for the first or last occurrence, you would modify the binary search to continue searching left or right respectively. This shows you understand the nuances of binary search with duplicates.

1. Clarify requirements and constraints

Confirm that the array is sorted, may contain duplicates, and that any valid index is acceptable. Ask about edge cases like empty array or target not present.

2. Choose binary search

Explain that binary search is ideal for O(log n) search in a sorted array. Since any index is acceptable, a standard binary search that returns upon finding the target works.

3. Outline the algorithm

Initialize low and high pointers. While low <= high, compute mid, compare array[mid] with target, and adjust pointers accordingly. Return mid if found, else -1.

4. Walk through an example

Pick a small array with duplicates and trace the algorithm to demonstrate correctness, showing how it handles duplicates and returns a valid index.

5. Analyze complexity and edge cases

State time complexity O(log n) and space O(1). Discuss edge cases: empty array, single element, target smaller/larger than all elements, and all duplicates.

Key Points to Mention

  • Binary search algorithm and its O(log n) time complexity.
  • Handling duplicates: standard binary search returns any occurrence, which satisfies the requirement.
  • Edge cases: empty array, target not present, array with all duplicates.
  • Space complexity: iterative implementation uses O(1) extra space.
  • Comparison with linear search: O(n) vs O(log n) and why binary search is preferred.
  • Potential follow-up: finding first/last occurrence would require modified binary search.

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