Skip to main content

Meta Coding Interview Questions

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

Showing 32 problems of 32

  • #21mediumfoundational

    21. Number of Islands

    Count connected land regions in a 2D grid — Meta uses this BFS/DFS pattern directly in social-graph clustering and detecting connected communities in their global friend network.

  • #22mediumfoundational

    22. Clone Graph

    Deep-copy an undirected graph — Meta's social network literally deep-copies subgraph views for privacy sandboxing, making this BFS/DFS-with-hash-map pattern a genuine engineering analog used in production systems.

  • #23mediumfoundational

    23. K Closest Points to Origin

    Find the k nearest geographic points to a center — Meta's location-based friend discovery and venue recommendations run exactly this top-K proximity filter at massive scale every second across billions of location signals.

  • #24mediumfoundational

    24. Merge Intervals

    Collapse overlapping time windows into a minimal set — Meta's event-scheduling system, ad-slot deduplication, and calendar integrations all rely on this interval-merge pattern at their core.

  • #25hardfoundational

    25. Serialize and Deserialize Binary Tree

    Convert a binary tree to a string and back — Meta's news-feed comment-thread storage serializes hierarchical tree structures to bytes for transmission and reconstruction at billion-user scale every day.

  • #26hardfoundational

    26. Remove Invalid Parentheses

    Generate all minimum-removal results to make parentheses valid — Meta's search query parser and structured-message sanitizer use exactly this BFS enumeration to recover gracefully from malformed user input at scale.

  • #27easyfoundational

    27. Valid Word Abbreviation

    Check if a numeric abbreviation is valid for a word — Meta's search autocomplete and username compression features depend on this two-pointer string matching to validate user-typed abbreviations instantly.

  • #28mediumfoundational

    28. Decode Ways

    Count ways to decode a digit string into letters — Meta's notification encoding and push-message compression pipelines use DP-based decoding to count valid parse paths through variable-length encoded payloads at scale.

  • #29hardfoundational

    29. Sliding Window Maximum

    Track the maximum value in a moving window — Meta's real-time engagement analytics and feed-ranking score smoothing rely on this monotonic deque pattern to compute rolling metrics over billions of events per day.

  • #30hardfoundational

    30. Word Search II

    Find all dictionary words on a 2D character board — Meta's AR text-recognition and content-moderation grid scanners use trie-backed DFS to match thousands of patterns simultaneously without redundant board traversals.

  • #31mediumfoundational

    31. Find All Anagrams in a String

    Find every starting index where a pattern's anagram appears in text — Meta's content-search and hashtag-matching pipelines use this sliding-window frequency-map pattern to surface variations without expensive sort-based comparisons.

  • #32mediumfoundational

    32. Binary Tree Right Side View

    Return the last visible node at each tree level — Meta's comment-threading UI renders the rightmost visible reply at each nesting depth, and feed-ranking previews use this BFS level-order traversal pattern to surface the most prominent item per tier.

  • #50mediumfrequently asked

    50. Pow(x, n)

    Compute x raised to the n-th power. Meta asks this to test whether you reach for the O(log n) fast-exponentiation pattern and can handle the negative exponent edge case.

  • #67easyfoundational

    67. Add Binary

    Given two binary strings, return their sum as a binary string. Meta asks this to test whether you can simulate column addition without converting to integers (numbers can exceed int64).

  • #71mediumfrequently asked

    71. Simplify Path

    Given an absolute Unix-style path, return the canonical simplified form. Meta asks this to test whether you reach for stack-based processing of path segments and handle the '..', '.', and consecutive-slash edge cases correctly.

  • #125easyfoundational

    125. Valid Palindrome

    Given a string, return true if it's a palindrome after lowercasing and ignoring non-alphanumeric characters. Meta asks this to test whether you reach for the two-pointer in-place approach instead of building a cleaned copy of the string.

  • #138mediumfrequently asked

    138. Copy List With Random Pointer

    Deep-copy a linked list where each node has a random pointer in addition to next. Meta asks this to test whether you can handle the two-pass map approach or the elegant O(1)-space interleaving trick.

  • #215mediumfrequently asked

    215. Kth Largest Element in an Array

    Return the k-th largest element in an unsorted array. Meta asks this to test whether you reach for a min-heap of size k or quickselect, and can articulate the n log k vs O(n) average tradeoff.

  • #227mediumfrequently asked

    227. Basic Calculator II

    Evaluate a string expression with +, -, *, / and non-negative integers. Meta asks this to test whether you reach for the stack-based delayed-add pattern that handles precedence without recursion or explicit token parsing.

  • #314mediumcompany favorite

    314. Binary Tree Vertical Order Traversal

    Given a binary tree, return its vertical order traversal of node values. Meta asks this to test whether you reach for BFS with column tracking (so left children get column - 1 and right children get column + 1).

  • #523mediumfrequently asked

    523. Continuous Subarray Sum

    Given an array and integer k, return true if there's a contiguous subarray of size at least 2 whose sum is a multiple of k. Meta asks this to test whether you reach for prefix sums + mod and articulate the 'same remainder means divisible difference' trick.

  • #528mediumcompany favorite

    528. Random Pick With Weight

    Given a positive-integer weights array, implement pickIndex() that returns i with probability proportional to w[i]. Meta asks this to test whether you reach for prefix sums + binary search and can articulate the uniform-random-on-[0, total) framing.

  • #543easyfrequently asked

    543. Diameter of Binary Tree

    Return the length of the longest path between any two nodes in a binary tree. Meta asks this to test whether you grasp the dual-return-vs-side-effect pattern in tree recursion — same shape as Binary Tree Maximum Path Sum but easier numbers.

  • #560mediumfrequently asked

    560. Subarray Sum Equals K

    Given an integer array and integer k, return the count of contiguous subarrays whose sum equals k. Meta asks this to test whether you reach for the prefix-sum + hash map pattern and articulate the 'count[prefixSum - k]' trick.

  • #670mediumfrequently asked

    670. Maximum Swap

    Given a non-negative integer, you may swap two digits at most once to get the maximum valued number. Meta asks this to test whether you reach for the 'find largest later digit to swap with earliest smaller digit' greedy.

  • #680easycompany favorite

    680. Valid Palindrome II

    Given a string, return true if you can make it a palindrome by deleting at most one character. Meta asks this to test whether you can adapt the two-pointer palindrome check to branch on a single mismatch without recursing or losing O(n) time.

  • #721mediumfrequently asked

    721. Accounts Merge

    Given accounts with emails, merge accounts that share any email (transitively). Meta asks this to test whether you reach for union-find or BFS/DFS on an implicit graph and articulate the connected-components framing.

  • #986mediumfrequently asked

    986. Interval List Intersections

    Given two sorted lists of disjoint intervals, return the intersection. Meta asks this to test whether you reach for the two-pointer pattern and articulate why it's O(m+n) instead of O(m*n).

  • #1091mediumfrequently asked

    1091. Shortest Path in Binary Matrix

    Find the shortest path in a binary matrix from top-left to bottom-right, moving through 0-cells in 8 directions. Meta asks this to test whether you reach for BFS for shortest-path on unweighted grids.

  • #1249mediumcompany favorite

    1249. Minimum Remove to Make Valid Parentheses

    Given a string with letters and parens, remove the minimum number of parens to make it valid. Meta asks this to test whether you can identify removals in a single stack pass (forward + backward sweeps work too).

  • #1762mediumcompany favorite

    1762. Buildings With an Ocean View

    Given building heights, return indices that can see the ocean to the right. Meta asks this to test whether you reach for the right-to-left sweep that's O(n), not the O(n^2) per-building lookahead.

Related interview-prep guides

Interview Platforms

HireVue Tech Interview Guide: The 2026 Playbook for Async Video Rounds

HireVue is the category-leading async video interview platform. Candidates record answers solo, on the clock, and a combined AI-plus-human review layer scores the recording days later. For 2026 tech jobseekers, the format is different enough from live interviews to need its own playbook. This guide is that playbook.

Interview Platforms

CodeSignal GCA for Tech Interviews in 2026: The Complete Guide

The CodeSignal General Coding Assessment is a 70-minute, four-task timed test scored on a 600 to 850 scale, used as a filter by Goldman Sachs, Capital One, Robinhood, Brex, and a growing list of tech and finance employers. This guide breaks down what it tests, how it scores, what it tracks during your session, and how a modern desktop setup pairs with it without showing up in proctored recordings.

Interview Platforms

CoderPad Live Coding Interview Guide (2026): What the Pad Tracks and How to Walk Through It Cleanly

CoderPad is the default live-coding environment for human-led technical interviews in 2026. Used by YC startups, FAANG-tier teams, and most of the tech mid-market. The pad records every keystroke, every paste event, every language switch, and offers an interviewer scrub-back feature most candidates never realize exists. This is what CoderPad tracks, how the live session compares to async assessments, and how a modern desktop AI setup pairs with it without showing up in the screen-share.

Meta Coding Interview Questions — Full Solutions — InterviewChamp.AI