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 30 problems of 30

  • #1easyfoundational

    1. Two Sum

    Two Sum is Pinterest's warm-up screening question: given an integer array and a target, return the indices of two numbers that add up to the target. The interviewer is checking that you can articulate the space-for-time tradeoff before writing the optimal hash-map solution.

    4 free resourcesSolve →
  • #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 →
  • #20easyfoundational

    20. Valid Parentheses

    Valid Parentheses is a Pinterest phone-screen staple: given a string of brackets, determine whether they are balanced. The interviewer is checking that you reach for a stack the moment you see nested matching, not nested loops.

    4 free resourcesSolve →
  • #23hardfrequently asked

    23. Merge k Sorted Lists

    Pinterest's feed-serving merges sorted streams from N candidate sources every request. Merge k Sorted Lists asks you to merge k sorted linked lists into one sorted list — the min-heap is the canonical answer, with divide-and-conquer as a heap-free alternative.

    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 →
  • #124hardfrequently asked

    124. Binary Tree Maximum Path Sum

    Binary Tree Maximum Path Sum is Pinterest's signature tree-DP problem: find the maximum sum of any path through any nodes (path need not pass through root). The interviewer wants the classic 'return one side, consider both sides' postorder pattern.

    4 free resourcesSolve →
  • #127hardfrequently asked

    127. Word Ladder

    Word Ladder is Pinterest's canonical BFS-on-implicit-graph problem: given a start word, end word, and word list, find the shortest transformation sequence changing one letter at a time. The interviewer wants the wildcard-bucket BFS optimization, not naive pairwise edge construction.

    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 →
  • #212hardcompany favorite

    212. Word Search II

    Word Search II is Pinterest's canonical 'trie + grid DFS' problem and a feared L5 onsite. Given a 2D board and a list of dictionary words, return every word found by walking adjacent cells without reuse. The trick is sharing the dictionary across DFS attempts.

    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 →
  • #295hardcompany favorite

    295. Find Median from Data Stream

    Pinterest's metrics infrastructure tracks rolling medians for latency and engagement signals. Find Median from Data Stream asks you to support addNum and findMedian on an online stream — the two-heap pattern is the production answer.

    4 free resourcesSolve →
  • #297hardcompany favorite

    297. Serialize and Deserialize Binary Tree

    Pinterest stores trees-shaped data — board hierarchies, comment threads — in caches and databases that need a string representation. Serialize and Deserialize Binary Tree asks you to convert a tree to a string and back while preserving structure. The interviewer wants either preorder DFS or BFS with null markers.

    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 →
  • #642hardcompany favorite

    642. Design Search Autocomplete System

    Pinterest's search bar autocompletes pins and boards as you type; this LeetCode design problem mirrors the production setup. Build a system that, given a stream of historical queries with hot-counts, returns the top-3 ranked completions for any prefix typed so far. Trie + heap is the canonical answer.

    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