Skip to main content

Pinterest Coding Interview Questions

30 Pinterest coding interview problems with full optimal solutions — 2 easy, 21 medium, 7 hard. Every problem ships with multiple approaches (brute-force first, then the optimal), complexity tables for each, company-specific tips on what an Pinterest interviewer values, and a FAQ section.

Showing 21 problems of 30

  • #3mediumfrequently asked

    3. Longest Substring Without Repeating Characters

    Pinterest's go-to sliding-window question: given a string, find the longest substring with no repeating characters. The interviewer wants the variable-window two-pointer pattern with a hash map of character-to-most-recent-index.

    4 free resourcesSolve →
  • #49mediumfrequently asked

    49. Group Anagrams

    Group Anagrams is Pinterest's go-to hash-map problem: given an array of strings, group strings that are anagrams of each other. The interviewer wants you to pick a canonical signature (sorted string OR character-count tuple) and articulate the tradeoff.

    4 free resourcesSolve →
  • #53mediumfrequently asked

    53. Maximum Subarray

    Maximum Subarray is Pinterest's go-to dynamic-programming warm-up: given an integer array, find the contiguous subarray with the largest sum. The interviewer wants to see you derive Kadane's algorithm from first principles, not recite it.

    4 free resourcesSolve →
  • #56mediumfrequently asked

    56. Merge Intervals

    Merge Intervals is Pinterest's canonical interval-handling problem: given an array of [start, end] intervals, merge all overlapping ones and return the result. The interviewer wants the sort-then-sweep pattern, not nested loops.

    4 free resourcesSolve →
  • #102mediumfrequently asked

    102. Binary Tree Level Order Traversal

    Binary Tree Level Order Traversal is a Pinterest tree-traversal warm-up: return node values grouped by level top-to-bottom. The interviewer wants BFS with a level-size snapshot — get the pattern right and they'll pivot to harder tree problems.

    4 free resourcesSolve →
  • #146mediumcompany favorite

    146. LRU Cache

    Pinterest asks LRU Cache because their feed-serving infrastructure relies on bounded-memory caches for hot pins. The interviewer wants to see you reach for the doubly-linked-list + hash map combo and explain why neither data structure alone gives O(1) for both get and put.

    4 free resourcesSolve →
  • #150mediumfrequently asked

    150. Evaluate Reverse Polish Notation

    Evaluate Reverse Polish Notation is a Pinterest stack warm-up: given tokens in postfix notation, evaluate the expression. The interviewer is checking that you reach for a stack and handle integer division truncation correctly.

    4 free resourcesSolve →
  • #200mediumfrequently asked

    200. Number of Islands

    Number of Islands is Pinterest's canonical graph-traversal problem: given a 2D grid of '1's (land) and '0's (water), count the distinct islands. The interviewer wants either BFS or DFS flood-fill — pick one, narrate the traversal invariant, ship.

    4 free resourcesSolve →
  • #207mediumfrequently asked

    207. Course Schedule

    Course Schedule is Pinterest's go-to cycle-detection problem: given course prerequisites as edges, decide whether you can finish every course. The interviewer wants a topological sort or DFS three-color cycle check — pick one and execute it cleanly.

    4 free resourcesSolve →
  • #208mediumcompany favorite

    208. Implement Trie (Prefix Tree)

    Pinterest's search-suggest and tag-autocomplete services run on tries. Implement Trie asks you to build a prefix tree supporting insert, search, and startsWith — and the interviewer will pivot to a harder follow-up the moment yours works.

    4 free resourcesSolve →
  • #215mediumfrequently asked

    215. Kth Largest Element in an Array

    Pinterest's ranking pipelines need fast top-K selection. Kth Largest Element asks you to find the kth largest in an unsorted array; the interviewer wants either a size-K min-heap or a Quickselect with mid-of-three pivot — bonus if you can articulate when each is appropriate.

    4 free resourcesSolve →
  • #236mediumfrequently asked

    236. Lowest Common Ancestor of a Binary Tree

    Lowest Common Ancestor is Pinterest's go-to tree-recursion problem: given two nodes in a binary tree, return their deepest common ancestor. The interviewer wants the postorder 'return target nodes upward and join at the split point' pattern.

    4 free resourcesSolve →
  • #253mediumfrequently asked

    253. Meeting Rooms II

    Pinterest asks Meeting Rooms II because its scheduling / capacity-planning systems (and ads-pacing controllers) all reduce to 'max concurrent intervals.' Given a list of meeting intervals, return the minimum number of conference rooms required.

    4 free resourcesSolve →
  • #347mediumcompany favorite

    347. Top K Frequent Elements

    Pinterest's recommendation infrastructure runs top-K queries everywhere: trending pins, top boards by engagement, most-clicked categories. Top K Frequent Elements asks you to return the K most-frequent numbers; the interviewer wants either the heap or bucket-sort solution depending on the input shape.

    4 free resourcesSolve →
  • #355mediumcompany favorite

    355. Design Twitter

    Design Twitter is Pinterest's favorite social-graph design problem: build a feed where users follow others, post tweets, and read a merged most-recent-10 feed. The interviewer is checking whether you reach for the k-way-merge / min-heap pattern that production feed-serving uses.

    4 free resourcesSolve →
  • #362mediumcompany favorite

    362. Design Hit Counter

    Pinterest's ads / metrics infrastructure runs on sliding-window counters. Design Hit Counter asks you to support hit(timestamp) and getHits(timestamp) over the last 300 seconds — the bucketed circular-array pattern is what production rate-limiters and impression counters use.

    4 free resourcesSolve →
  • #380mediumcompany favorite

    380. Insert Delete GetRandom O(1)

    Pinterest's experimentation and A/B-testing infrastructure picks random users from a live cohort. Insert Delete GetRandom O(1) asks you to build a set with O(1) add, remove, and uniform random sample — the dynamic-array + index-map combo is the canonical answer.

    4 free resourcesSolve →
  • #528mediumcompany favorite

    528. Random Pick with Weight

    Pinterest's ads-pacing and ranking infrastructure samples from weighted distributions. Random Pick with Weight asks you to build a sampler where each index i is picked with probability proportional to w[i]. The interviewer wants the prefix-sum + binary-search pattern.

    4 free resourcesSolve →
  • #535mediumfrequently asked

    535. Encode and Decode TinyURL

    Encode and Decode TinyURL is Pinterest's coding-round analog to its production short-link / pin-sharing service. Build a URL shortener: encode(longUrl) returns a short URL; decode(shortUrl) returns the original. The interviewer wants to see you pick a deterministic ID scheme and discuss collision avoidance.

    4 free resourcesSolve →
  • #560mediumfrequently asked

    560. Subarray Sum Equals K

    Subarray Sum Equals K is Pinterest's prefix-sum classic: given an array and an integer k, count the contiguous subarrays whose sum equals k. The interviewer wants the prefix-sum + hash-map count pattern that handles negative numbers correctly.

    4 free resourcesSolve →
  • #767mediumfrequently asked

    767. Reorganize String

    Reorganize String is Pinterest's go-to greedy + heap problem: given a string s, rearrange it so no two adjacent characters are the same. The interviewer wants the count-then-emit-highest pattern using a max-heap by frequency.

    4 free resourcesSolve →
Pinterest Coding Interview Questions — Full Solutions — InterviewChamp.AI