← Pinterest Interview Insights

Pinterest·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jul 2026Remote

Summary

Pinterest SWE interview with a binary search problem that looked like a scheduling question but was really just math dressed up fancy. One round, one meaty problem, lots of follow-ups.

Questions Asked (1)

Q1

You have a bank with k tellers, where teller i takes serviceTimes[i] minutes per customer. Given a target number of customers m, find the minimum time T such that the total customers served across all tellers is at least m. Walk through your algorithm, prove it's correct, analyze complexity, implement it, and cover edge cases like very large m, slow tellers, or identical service rates.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Binary search on the answer, which I actually got to pretty fast.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as finding the minimum time T such that the total number of customers served by all tellers within T minutes is at least m. Use binary search on T, where the feasibility check sums floor(T / serviceTimes[i]) for all tellers. Then prove correctness, analyze complexity, and implement with attention to edge cases.

Pro tip: Mention that the answer can be found by binary searching on the time, and that the upper bound can be set to min(serviceTimes) * m to avoid overflow and ensure efficiency. Also, discuss how to handle very large m by using 64-bit integers and early termination in the feasibility check.

1. Understand the problem and define the search space

Clarify that we need the minimum time T for at least m customers. The search space is from 0 to an upper bound like min(serviceTimes) * m, since the fastest teller alone can serve m customers in that time.

2. Design a feasibility check for a given T

For a candidate T, compute the total customers served as the sum of floor(T / serviceTimes[i]) for all tellers. If this sum is >= m, T is feasible.

3. Apply binary search to find the minimum feasible T

Binary search on T between low=0 and high=min(serviceTimes)*m. While low < high, compute mid, check feasibility, and adjust bounds accordingly. Return low as the answer.

4. Prove correctness and analyze complexity

Argue that the feasibility function is monotonic: if T works, any larger T also works. Thus binary search finds the minimum. Complexity: O(k log(min(serviceTimes)*m)) time, O(1) space.

5. Implement and handle edge cases

Write code with 64-bit integers to avoid overflow. Handle cases like m=0 (return 0), very large m (ensure high bound doesn't overflow), slow tellers (serviceTimes large), and identical rates (sum simplifies to k * floor(T / rate)).

Key Points to Mention

  • Binary search on the answer (time T) with a monotonic feasibility condition.
  • Feasibility check: sum of floor(T / serviceTimes[i]) >= m.
  • Upper bound for binary search: min(serviceTimes) * m (or a safe large value).
  • Time complexity: O(k log(min(serviceTimes)*m)), space O(1).
  • Use 64-bit integers to prevent overflow when m is very large.
  • Edge cases: m=0, all tellers identical, very slow tellers, and early termination in feasibility check if sum exceeds m.

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