← Pinterest Interview Insights

Pinterest·Software Engineer·Technical Phone Screen·Intermediate

IntermediateRejected
May 2026Remote

Summary

Phone screen for a software engineer role at Pinterest, roughly an hour long. The main coding problem was manageable since I'd seen it before, but a follow-up variant tripped me up and I think that's what sank it.

Questions Asked (2)

Q1

Solve LeetCode 1564 (Put Boxes Into the Warehouse I).

Algorithms & Data Structures
Author's notes

Had actually drilled this one before the call so it went fine.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the problem constraints and edge cases, then propose a greedy strategy: sort boxes in descending order and preprocess the warehouse to compute the effective height at each position (the minimum height from the left up to that position). Iterate through the warehouse from right to left, placing the largest possible box at each step, and count how many boxes can be placed.

Pro tip: Mention that the greedy approach works because placing larger boxes first maximizes the remaining space, and the preprocessing step ensures we respect the non-increasing height constraint. Also, discuss time complexity: O(n log n + m) where n is number of boxes and m is warehouse length.

1. Understand the problem and constraints

Restate the problem: given boxes and warehouse heights, determine the maximum number of boxes that can be placed from left to right without exceeding the height at any position. Clarify that boxes can only be placed if their height is ≤ the effective height at that position, and the effective height is the minimum of all heights to the left.

2. Preprocess the warehouse

Compute an array of effective heights by taking the running minimum from left to right. This ensures that at any position i, the height is the minimum of warehouse[0..i], reflecting the constraint that boxes cannot be placed if they exceed any previous height.

3. Sort boxes and use greedy placement

Sort the boxes in descending order. Then iterate through the warehouse from right to left, placing the largest box that fits at each position. If a box fits, increment the count and move to the next box; otherwise, move to the next position.

4. Analyze complexity and edge cases

Discuss time complexity: sorting boxes takes O(n log n), preprocessing warehouse takes O(m), and the greedy placement takes O(n + m). Space complexity is O(m) for the effective heights array. Consider edge cases: empty boxes, empty warehouse, boxes taller than any warehouse position.

Key Points to Mention

  • Greedy strategy: placing larger boxes first maximizes the number of boxes that can fit.
  • Preprocessing the warehouse to compute effective heights (running minimum from left).
  • Sorting boxes in descending order to facilitate greedy placement.
  • Iterating from right to left in the warehouse to place boxes.
  • Time complexity: O(n log n + m) and space complexity: O(m).
  • Edge cases: no boxes, no warehouse, boxes taller than all warehouse positions.

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

Q2

Follow-up: given the same warehouse problem, how would you maximize the total height of all boxes placed, rather than just the count?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This is where things fell apart.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Recognize that maximizing total height is a weighted interval scheduling problem where each box has a value equal to its height. Adapt the DP recurrence to maximize sum of heights instead of count, and discuss trade-offs like time/space complexity and potential optimizations.

Pro tip: Explicitly state that the problem is a variation of the classic 'box stacking' or 'weighted interval scheduling' problem, and show how a small change in the DP state transition yields the solution. This demonstrates pattern recognition and adaptability.

1. Clarify the problem

Confirm that boxes have dimensions (length, width, height) and can be rotated, and that stacking requires strictly smaller base dimensions. Also confirm that 'total height' means the sum of heights of all boxes in the stack.

2. Define DP state

Define dp[i] as the maximum total height of a stack with box i at the bottom (or top). The recurrence: dp[i] = height[i] + max(dp[j]) for all j that can be placed on i.

3. Sort and iterate

Sort boxes by base area (or one dimension) to ensure we only consider valid stacking orders. Iterate through boxes, computing dp[i] using previously computed dp[j] for smaller boxes.

4. Handle rotations

Generate all possible orientations of each box (up to 3 unique ones) and treat each as a separate item. Ensure that when comparing, the base dimensions are strictly smaller.

5. Return result and analyze

The answer is the maximum value in dp. Discuss time complexity O(n^2) and space O(n), and mention possible optimizations like using a segment tree for O(n log n) if needed.

Key Points to Mention

  • The problem is a weighted interval scheduling / box stacking variant.
  • DP recurrence: dp[i] = height[i] + max(dp[j]) for valid j.
  • Sorting by base area simplifies the comparison and ensures acyclic dependencies.
  • Rotations increase the number of items to consider (up to 3n).
  • Time complexity O(n^2) with potential optimization to O(n log n).
  • Trade-off: maximizing height may require different sorting or data structures than maximizing count.

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