← Whatnot Interview Insights

Whatnot·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Did a technical phone screen for a software engineer role at Whatnot. Pretty short session, just one coding problem and that was about it.

Questions Asked (1)

Q1

Given a sorted array of integers, return a new array of the squares of each number, also in sorted order.

Algorithms & Data Structures
Author's notes

Classic two-pointer problem once you see it, but I fumbled around for a bit thinking about just squaring everything and sorting after.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints and edge cases, then propose a two-pointer approach that leverages the sorted order to build the result in O(n) time. Explain why squaring and sorting naively is O(n log n) and how the two-pointer method improves it. Walk through a small example to demonstrate correctness.

Pro tip: Mention that the largest squares come from either end of the array, so comparing absolute values from both ends lets you fill the result from the back in one pass. This shows you understand the structure of the problem, not just the algorithm.

1. Clarify and Confirm

Ask about input size, whether the array can contain negative numbers, and if duplicates or empty arrays are possible. Confirm that the output should be a new array, not in-place.

2. Discuss Naive Approach

Mention the straightforward solution: square each element and sort the result, which takes O(n log n) time. Acknowledge it works but isn't optimal given the sorted input.

3. Propose Optimal Two-Pointer Approach

Explain that since the array is sorted, the largest squared values are at the extremes. Use two pointers starting at both ends, compare absolute values, and place the larger square at the end of the result array, moving inward.

4. Walk Through Example

Trace the algorithm on a sample input like [-4, -1, 0, 3, 10] to show how the result is built from the back, ensuring the candidate demonstrates understanding.

5. Analyze Complexity and Edge Cases

State that time complexity is O(n) and space complexity is O(n) for the output array. Discuss edge cases like empty array, all negatives, all positives, and zeros.

Key Points to Mention

  • The array is sorted, so the largest squares are at the ends (due to absolute values).
  • Two-pointer technique: left and right pointers, compare squares, fill result from the end.
  • Time complexity O(n) vs O(n log n) for naive sort.
  • Space complexity O(n) for the new array (output).
  • Handling negative numbers: squaring makes them positive, so absolute value comparison is key.
  • Edge cases: empty array, single element, all negative, all positive, duplicates.

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