Meta Coding Interview Questions: OA, Phone Screen & Onsite | New Grad, E3, E4 & Intern

Meta (formerly Facebook) is one of the most competitive software engineering destinations in the world. Their hiring bar is consistently high across all levels — from New Grad (E3) to Senior (E5). This page compiles actual reported coding questions from Meta's Online Assessment, Phone Screen, and Onsite rounds sourced from LeetCode Discuss, Glassdoor, Blind, and verified candidate reports (2023–2026).

Meta's Hiring Process for SWE Roles (2026)

1. Online Application

  • Apply via metacareers.com. Referrals significantly improve invite rates — Meta employees can refer directly through an internal portal.
  • Tip: Highlight impact with numbers. "Built a caching layer that reduced API latency by 40% for 10M daily users" beats "built a caching layer." Meta values scale and measurable outcomes.

2. Online Assessment (OA) — 70–90 minutes

  • 2–3 coding problems on HackerRank, proctored. Mostly Medium difficulty.
  • All problems are visible from the start — read both before starting.
  • Tip: Partial test case passes still count. Get the brute force working first, then optimise before time runs out.

3. Recruiter Call — 15–20 minutes

  • Non-technical. Covers motivation, experience, level targeting (E3/E4), location, and timeline.
  • Tip: Be direct about your target level and timeline. Recruiters move faster when expectations are clear.

4. Phone Screen — 35 minutes (Elimination Round)

  • 2 LeetCode-style problems with a Meta engineer on a shared coding environment.
  • Mostly Medium, occasionally one Easy + one Hard combo.
  • Tip: Think out loud from the start. Meta interviewers evaluate communication as much as correctness. State your approach, edge cases, and complexity before writing a single line.

5. Virtual Onsite — 4–5 Rounds (45 min each)

  • Coding Rounds (2): 2 problems per round, Medium to Hard. Expect follow-ups on every solution.
  • System Design (E4+): Design scalable systems (Instagram Feed, Messenger, Ad Delivery).
  • Behavioural Round: Meta uses the STAR format with a focus on ownership, speed, and impact — their core values.

6. Hiring Committee → Offer

  • HC reviews all round scorecards. Levelling decision (E3 vs E4) is made here.
  • Offers typically come within 1–2 weeks of final round completion.

Preparation Resources

Part 1 — Online Assessment (OA)

Meta's OA is hosted on HackerRank. You get 2–3 problems in 90 minutes. Questions are typically Medium difficulty with one potential Hard. The OA is proctored and tests fundamental DSA skills.


1. Valid Palindrome II Easy

OATwo Pointers · StringsLeetCode:#680

Given a string s, return true if it can become a palindrome after deleting at most one character.

Input:  s = "abca"
Output: true
Explanation: Delete 'b' or 'c' to get "aca" or "aba"

Approach: Use two pointers from both ends. When a mismatch is found, try skipping either the left or right character and check if the remaining substring is a palindrome.

Complexity: Time O(n) · Space O(1)

Follow-up: What if you can delete at most k characters?


2. Subarray Sum Equals K Medium

OAPrefix Sum · HashingLeetCode:#560

Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals k.

Input:  nums = [1,1,1], k = 2
Output: 2

Approach: Use a prefix sum hash map. At each index, check if prefixSum - k exists in the map. This avoids the O(n²) brute force.

Complexity: Time O(n) · Space O(n)

Follow-up: Can you handle negative numbers? (Yes — prefix sum approach handles them naturally.)


3. Merge Intervals Medium

OASorting · ArraysLeetCode:#56

Given an array of intervals, merge all overlapping intervals and return the result.

Input:  intervals = [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]

Approach: Sort by start time. Iterate and extend the last merged interval if the current start is within the previous end. Otherwise push a new interval.

Complexity: Time O(n log n) · Space O(n)

Follow-up: What if intervals are added in a stream? (Use a sorted data structure like a balanced BST.)


4. Move Zeroes Easy

OATwo Pointers · ArraysLeetCode:#283

Given an integer array nums, move all 0s to the end while maintaining the relative order of non-zero elements. Do it in-place.

Input:  nums = [0,1,0,3,12]
Output: [1,3,12,0,0]

Approach: Use a write pointer. Iterate through the array writing non-zero values, then fill the rest with zeros.

Complexity: Time O(n) · Space O(1)

Follow-up: Minimise total operations (writes). Use the snowball approach — swap instead of overwrite.


5. Product of Array Except Self Medium

OAPrefix Product · ArraysLeetCode:#238

Return an array output where output[i] is the product of all elements except nums[i]. Cannot use division.

Input:  nums = [1,2,3,4]
Output: [24,12,8,6]

Approach: Two-pass prefix and suffix product. First pass fills prefix products left-to-right, second pass multiplies suffix products right-to-left in-place.

Complexity: Time O(n) · Space O(1) (output array not counted)

Follow-up: What if zeros exist in the array? Handle single-zero and multi-zero cases separately.


6. Group Anagrams Medium

OAHashing · StringsLeetCode:#49

Given an array of strings, group the anagrams together. Return the groups in any order.

Input:  strs = ["eat","tea","tan","ate","nat","bat"]
Output: [["bat"],["nat","tan"],["ate","eat","tea"]]

Approach: Use a hash map keyed by the sorted version of each string. All anagrams will share the same sorted key.

Complexity: Time O(n · k log k) where k is max string length · Space O(n · k)

Follow-up: What if sorting is too slow? Use a character frequency tuple as the key instead.

Part 2 — Phone Screen

Meta's phone screen is 35 minutes with one Meta engineer. You'll get 2 LeetCode-style questions — usually one Easy/Medium and one Medium. Speed and communication are both evaluated.


7. Binary Tree Right Side View Medium

Phone ScreenBFS · TreesLeetCode:#199

Given the root of a binary tree, imagine standing on its right side. Return the values of the nodes visible from the right side, ordered top to bottom.

Input:  root = [1,2,3,null,5,null,4]
Output: [1,3,4]

Approach: Level-order BFS. At each level, the last node in the queue is the rightmost visible node. Alternatively, DFS with right-child-first traversal.

Complexity: Time O(n) · Space O(n)

Follow-up: What if we want the left side view instead? Simply take the first node at each BFS level.


8. Minimum Remove to Make Valid Parentheses Medium

Phone ScreenStack · StringsLeetCode:#1249

Given a string s of (, ), and lowercase English characters, remove the minimum number of parentheses to make it valid. Return any valid result.

Input:  s = "lee(t(c)o)de)"
Output: "lee(t(c)o)de"

Approach: Use a stack to track indices of unmatched (. Do a second pass to mark unmatched ). Build result string skipping marked indices.

Complexity: Time O(n) · Space O(n)

Follow-up: What if you need to return the lexicographically smallest result?


9. Lowest Common Ancestor of Binary Tree Medium

Phone ScreenDFS · TreesLeetCode:#236

Given a binary tree and two nodes p and q, find their lowest common ancestor (LCA). The LCA is the deepest node that has both p and q as descendants.

Input:  root = [3,5,1,6,2,0,8], p = 5, q = 1
Output: 3

Approach: Recursive post-order DFS. If the current node is p or q, return it. If both subtrees return non-null, current node is the LCA.

Complexity: Time O(n) · Space O(h) where h is tree height

Follow-up: What if nodes may not exist in the tree? Check return values more carefully.


10. Simplify Path Medium

Phone ScreenStack · StringsLeetCode:#71

Given a string path representing an absolute Unix file path, simplify it to its canonical form.

Input:  path = "/home//foo/"
Output: "/home/foo"

Input:  path = "/../"
Output: "/"

Approach: Split by /, process each token with a stack. Push valid directory names, pop on .., ignore . and empty strings.

Complexity: Time O(n) · Space O(n)

Follow-up: Handle symbolic links or relative paths.


11. Longest Substring Without Repeating Characters Medium

Phone ScreenSliding Window · HashingLeetCode:#3

Given a string s, find the length of the longest substring without repeating characters.

Input:  s = "abcabcbb"
Output: 3  (substring "abc")

Approach: Sliding window with a hash map storing the last seen index of each character. Shrink the window from the left when a repeat is found.

Complexity: Time O(n) · Space O(min(m, n)) where m is charset size

Follow-up: What if you need to return the actual substring, not just its length?


12. Kth Largest Element in an Array Medium

Phone ScreenHeap · QuickselectLeetCode:#215

Find the kth largest element in an unsorted array. Not the kth distinct element.

Input:  nums = [3,2,1,5,6,4], k = 2
Output: 5

Approach: Min-heap of size k — push elements and pop when size exceeds k. The heap root is the answer. Alternatively, Quickselect achieves O(n) average.

Complexity: Time O(n log k) with heap, O(n) average with Quickselect · Space O(k)

Follow-up: What if the array is a stream of unknown length?


13. Copy List with Random Pointer Medium

Phone ScreenLinked List · HashingLeetCode:#138

A linked list where each node has a next and a random pointer. Deep copy the entire list in O(n) time and O(1) extra space.

Input:  head = [[7,null],[13,0],[11,4],[10,2],[1,0]]
Output: Deep copy with same structure

Approach: Three-pass in-place: interleave cloned nodes, assign random pointers, then extract the cloned list. Avoids hash map.

Complexity: Time O(n) · Space O(1) (excluding output)

Follow-up: What if you use a hash map instead? Cleaner code but O(n) space.

Part 3 — Onsite / Virtual Onsite

The onsite consists of 2 coding rounds (45 min each), 1 system design, and 1 behavioural. Each coding round has 2 questions — typically one medium and one medium-hard. Questions are classic patterns with Meta-specific twists.


14. Vertical Order Traversal of a Binary Tree Medium

OnsiteBFS · Trees · SortingLeetCode:#987

Return the vertical order traversal of a binary tree's values. Nodes at the same position are sorted by value.

Input:  root = [3,9,20,null,null,15,7]
Output: [[9],[3,15],[20],[7]]

Approach: BFS with (col, row) coordinates for each node. Collect all (col, row, val) tuples, sort by col then row then val, and group by column.

Complexity: Time O(n log n) · Space O(n)

Follow-up: What if ties at the same (col, row) should be resolved by insertion order instead of value?


15. 3Sum Medium

OnsiteTwo Pointers · SortingLeetCode:#15

Find all unique triplets in the array that sum to zero. The solution set must not contain duplicate triplets.

Input:  nums = [-1,0,1,2,-1,-4]
Output: [[-1,-1,2],[-1,0,1]]

Approach: Sort the array. For each element nums[i], use two pointers (left = i+1, right = end) to find pairs summing to -nums[i]. Skip duplicates at each step.

Complexity: Time O(n²) · Space O(1) (excluding output)

Follow-up: What about 4Sum? Add one more outer loop and apply the same two-pointer trick.


16. Minimum Window Substring Hard

OnsiteSliding Window · HashingLeetCode:#76

Given strings s and t, return the minimum window substring of s containing all characters of t. If none exists, return "".

Input:  s = "ADOBECODEBANC", t = "ABC"
Output: "BANC"

Approach: Sliding window with two frequency maps. Expand right until all chars of t are covered, then shrink left to minimise window while maintaining coverage.

Complexity: Time O(|s| + |t|) · Space O(|t|)

Follow-up: What if you need all minimum windows, not just one?


17. Number of Islands Medium

OnsiteBFS/DFS · Graphs · GridLeetCode:#200

Given an m x n 2D binary grid, return the number of islands. An island is surrounded by water and formed by connecting adjacent '1's horizontally or vertically.

Input:  grid = [["1","1","0"],["0","1","0"],["0","0","1"]]
Output: 2

Approach: DFS or BFS flood-fill. For each unvisited '1', start a DFS marking all connected land cells as visited. Count each DFS call.

Complexity: Time O(m × n) · Space O(m × n) recursion stack

Follow-up: Number of Distinct Islands (LeetCode 694) — track the shape of each island.


18. Binary Tree Maximum Path Sum Hard

OnsiteDFS · Trees · DPLeetCode:#124

A path in a binary tree is a sequence of nodes where each pair of adjacent nodes has an edge. Find the path with maximum sum. The path does not need to pass through the root.

Input:  root = [-10,9,20,null,null,15,7]
Output: 42  (path: 15 → 20 → 7)

Approach: Post-order DFS. At each node, compute max gain from left and right subtrees (treat negative as 0). Update global max as node + left_gain + right_gain. Return node + max(left, right).

Complexity: Time O(n) · Space O(h)

Follow-up: What if you need to return the actual path nodes?


19. Serialize and Deserialize Binary Tree Hard

OnsiteBFS · Trees · DesignLeetCode:#297

Design an algorithm to serialize a binary tree to a string and deserialize it back to the original tree. No restriction on format.

Input:  root = [1,2,3,null,null,4,5]
Output: Deserialized tree matches original

Approach: BFS serialisation — encode level by level with "null" markers. Deserialization reconstructs level by level using a queue.

Complexity: Time O(n) · Space O(n)

Follow-up: Serialize an N-ary tree. Preorder DFS with child count per node.


20. Diameter of Binary Tree Easy

OnsiteDFS · TreesLeetCode:#543

Given the root of a binary tree, return the length of the diameter — the longest path between any two nodes. The path may or may not pass through the root.

Input:  root = [1,2,3,4,5]
Output: 3  (path: 4 → 2 → 1 → 3 or 5 → 2 → 1 → 3)

Approach: DFS returning height at each node. Track max(left_height + right_height) as the running diameter using a global variable.

Complexity: Time O(n) · Space O(h)

Follow-up: Meta variant — return the number of nodes on the diameter path, not edges.


21. Find Peak Element Medium

OnsiteBinary SearchLeetCode:#162

A peak element is one that is strictly greater than its neighbours. Given nums, find a peak element and return its index. The algorithm must run in O(log n).

Input:  nums = [1,2,3,1]
Output: 2

Approach: Binary search. If nums[mid] < nums[mid+1], peak is to the right; otherwise to the left. The boundary condition guarantees a peak exists.

Complexity: Time O(log n) · Space O(1)

Follow-up: Find all peaks in the array in O(n).


22. LRU Cache Medium

OnsiteDesign · Doubly Linked List · HashingLeetCode:&#35;146

Design a data structure for an LRU Cache with get(key) and put(key, value) operations, both in O(1) time.

Input:  capacity = 2, [put(1,1), put(2,2), get(1), put(3,3), get(2)]
Output: [null, null, 1, null, -1]

Approach: Doubly linked list + hash map. Map stores key-to-node pointers. List maintains access order — most recent at head, least recent at tail. On access, move node to head; on eviction, remove tail.

Complexity: Time O(1) for both operations · Space O(capacity)

Follow-up: Implement LFU Cache (LeetCode 460) — evict least frequently used.


23. All Nodes Distance K in Binary Tree Medium

OnsiteBFS · Trees · GraphLeetCode:&#35;863

Given the root of a binary tree, a target node, and an integer k, return all node values at distance k from the target.

Input:  root = [3,5,1,6,2,0,8], target = 5, k = 2
Output: [7,4,1]

Approach: Build a parent map via DFS. Then run BFS from the target node treating the tree as an undirected graph, stopping at depth k.

Complexity: Time O(n) · Space O(n)

Follow-up: What if k can be very large? BFS depth limit handles it naturally.


24. Word Search Medium

OnsiteBacktracking · DFS · GridLeetCode:&#35;79

Given an m x n grid of characters and a string word, return true if the word exists in the grid as a horizontally or vertically connected sequence without reusing cells.

Input:  board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCCED"
Output: true

Approach: DFS backtracking. For each cell matching word[0], DFS in four directions. Mark cells visited by temporarily changing the character; restore after recursion.

Complexity: Time O(m × n × 4^L) where L is word length · Space O(L)

Follow-up: Word Search II (LeetCode 212) — find all words from a list. Use a Trie for pruning.


25. Decode Ways Medium

OnsiteDynamic Programming · StringsLeetCode:&#35;91

A message encoded as a number string can be decoded where '1' maps to 'A', '2' to 'B', ..., '26' to 'Z'. Count the total ways to decode a given string.

Input:  s = "226"
Output: 3  ("2,2,6" = BBF, "22,6" = VF, "2,26" = BZ)

Approach: DP where dp[i] = ways to decode s[0..i-1]. Transition: add dp[i-1] if single digit valid; add dp[i-2] if two-digit (10–26) valid.

Complexity: Time O(n) · Space O(1) with two variables

Follow-up: Decode Ways II (LeetCode 639) with * wildcard character.


26. Making A Large Island Hard

OnsiteDFS · Graphs · GridLeetCode:&#35;827

You may change at most one 0 to 1. Return the size of the largest island.

Input:  grid = [[1,0],[0,1]]
Output: 3

Approach: Label each island with a unique ID and store its size. Then for each 0 cell, sum the sizes of distinct neighbouring islands plus 1. Track the max.

Complexity: Time O(n²) · Space O(n²)

Follow-up: What if you can flip at most k cells?


27. Buildings With an Ocean View Medium

OnsiteStack · MonotonicLeetCode:&#35;1762

Buildings face the right side (east). A building has an ocean view if all buildings to its right are shorter. Return the indices of buildings with an ocean view in increasing order.

Input:  heights = [4,2,3,1]
Output: [0,2,3]

Approach: Iterate right to left, maintaining the current maximum height seen. A building has an ocean view if its height is strictly greater than all buildings to its right.

Complexity: Time O(n) · Space O(1) (excluding output)

Follow-up: What if buildings can be on both sides of a river?


28. Clone Graph Medium

OnsiteBFS · Graphs · HashingLeetCode:&#35;133

Given a reference of a node in a connected undirected graph, return a deep copy of the graph.

Input:  adjList = [[2,4],[1,3],[2,4],[1,3]]
Output: Deep copy with same adjacency list

Approach: BFS or DFS with a hash map from original node to its clone. Visit each node once; for each neighbour, create clone if not seen, then add to current clone's neighbour list.

Complexity: Time O(V + E) · Space O(V)

Follow-up: What if the graph has cycles? (The hash map handles this — it prevents revisiting.)


29. Diagonal Traverse Medium

OnsiteMatrix · SimulationLeetCode:&#35;498

Given an m x n matrix, return all elements in diagonal order (alternating up-right and down-left direction).

Input:  mat = [[1,2,3],[4,5,6],[7,8,9]]
Output: [1,2,4,7,5,3,6,8,9]

Approach: Traverse diagonals by their index d = row + col. Collect elements of each diagonal, then reverse alternate diagonals before appending to output.

Complexity: Time O(m × n) · Space O(m × n)

Follow-up: Diagonal Traverse II (LeetCode 1424) with variable-length rows.


30. Implement Trie (Prefix Tree) Medium

OnsiteTrie · DesignLeetCode:&#35;208

Implement a Trie with insert(word), search(word), and startsWith(prefix) operations.

Input:  ["Trie","insert","search","startsWith"], [[],"apple","apple","app"]
Output: [null,null,true,true]

Approach: Each node stores a 26-element children array and an isEnd flag. Insert traverses/creates nodes character by character. Search and startsWith differ only in whether isEnd is checked at the end.

Complexity: Time O(m) per operation · Space O(m × n) for n words of avg length m

Follow-up: Add a delete(word) method. Mark isEnd = false; prune nodes with no children.


31. Maximum Swap Medium

OnsiteGreedy · MathLeetCode:&#35;670

Given a non-negative integer, you can swap two digits at most once to get the maximum valued number. Return the maximum.

Input:  num = 2736
Output: 7236

Approach: Record the last occurrence of each digit 0–9. Scan from left; for each digit, check if a larger digit appears later. Swap and return immediately.

Complexity: Time O(n) · Space O(1) (only 10 digits)

Follow-up: What if you can swap at most k times?


32. Course Schedule II Medium

OnsiteTopological Sort · GraphsLeetCode:&#35;210

Return the ordering in which you should take numCourses courses given prerequisites. If impossible (cycle), return an empty array.

Input:  numCourses = 4, prerequisites = [[1,0],[2,0],[3,1],[3,2]]
Output: [0,2,1,3]

Approach: Kahn's algorithm (BFS topological sort) using in-degree tracking. Start from nodes with in-degree 0, reduce neighbours' in-degrees, add to result when in-degree hits 0.

Complexity: Time O(V + E) · Space O(V + E)

Follow-up: Detect which specific cycle causes the impossibility.


33. Reorder List Medium

OnsiteLinked List · Two PointersLeetCode:&#35;143

Given a linked list L0 → L1 → ... → Ln, reorder it to L0 → Ln → L1 → Ln-1 → ... in-place.

Input:  head = [1,2,3,4,5]
Output: [1,5,2,4,3]

Approach: Three steps — find the middle (slow/fast pointer), reverse the second half, then merge both halves alternately.

Complexity: Time O(n) · Space O(1)

Follow-up: Detect if the list is already in reordered form.


34. Merge K Sorted Lists Hard

OnsiteHeap · Linked List · Divide and ConquerLeetCode:&#35;23

Merge k sorted linked lists into one sorted linked list.

Input:  lists = [[1,4,5],[1,3,4],[2,6]]
Output: [1,1,2,3,4,4,5,6]

Approach: Use a min-heap storing (value, list_index, node). Pop minimum, push next node from same list. Alternatively, divide and conquer — pair-wise merge in O(N log k).

Complexity: Time O(N log k) · Space O(k) heap

Follow-up: What if lists are too large to fit in memory? External merge sort.


35. Word Break Medium

OnsiteDP · Trie · StringsLeetCode:&#35;139

Given a string s and a dictionary of strings, return true if s can be segmented into a space-separated sequence of dictionary words.

Input:  s = "leetcode", wordDict = ["leet","code"]
Output: true

Approach: DP where dp[i] = true if s[0..i-1] can be segmented. For each i, check all j < i where dp[j] is true and s[j..i-1] is in the dict.

Complexity: Time O(n²) · Space O(n)

Follow-up: Word Break II (LeetCode 140) — return all valid segmentations.


36. Next Permutation Medium

OnsiteArray · Two PointersLeetCode:&#35;31

Rearrange a number's digits to produce the lexicographically next greater permutation. If no such arrangement exists, return the lowest order (ascending).

Input:  nums = [1,2,3]
Output: [1,3,2]

Input:  nums = [3,2,1]
Output: [1,2,3]

Approach: Find the rightmost descending pair (pivot). Find the smallest element to its right that is larger. Swap them. Reverse the suffix after the pivot.

Complexity: Time O(n) · Space O(1)

Follow-up: Generate all permutations in lexicographic order.


37. Add Two Numbers Medium

OnsiteLinked List · MathLeetCode:&#35;2

Two non-empty linked lists represent two non-negative integers in reverse order. Add the two numbers and return the sum as a linked list.

Input:  l1 = [2,4,3], l2 = [5,6,4]
Output: [7,0,8]  (342 + 465 = 807)

Approach: Simulate digit-by-digit addition with a carry variable. Create a new node for each digit sum. Handle remaining carry at the end.

Complexity: Time O(max(m, n)) · Space O(max(m, n) + 1)

Follow-up: Add Two Numbers II (LeetCode 445) — numbers stored in forward order. Use a stack or reverse first.


38. Is Graph Bipartite Medium

OnsiteBFS · Graph ColouringLeetCode:&#35;785

Determine if a graph is bipartite — whether its nodes can be split into two groups such that no two nodes in the same group are connected.

Input:  graph = [[1,2,3],[0,2],[0,1,3],[0,2]]
Output: false

Approach: BFS/DFS graph colouring with two colours. If an edge connects two same-coloured nodes, the graph is not bipartite. Handle disconnected components by starting BFS from every unvisited node.

Complexity: Time O(V + E) · Space O(V)

Follow-up: What if it's a directed graph?


39. Random Pick with Weight Medium

OnsiteBinary Search · Prefix Sum · ProbabilityLeetCode:&#35;528

Given an array of weights, implement pickIndex() so that index i is chosen with probability w[i] / sum(w).

Input:  w = [1,3]
Output: pickIndex() returns 0 with 25% chance, 1 with 75% chance

Approach: Build a prefix sum array. Generate a random number in [1, total_sum], then binary search for the first prefix sum that is >= random_number.

Complexity: Time O(n) init, O(log n) per pick · Space O(n)

Follow-up: What if weights update dynamically? Use a Fenwick tree for O(log n) updates.


40. Alien Dictionary Hard

OnsiteTopological Sort · Graphs · StringsLeetCode:&#35;269

Given a list of words sorted lexicographically in an alien language, determine the order of characters. Return the character order, or "" if invalid.

Input:  words = ["wrt","wrf","er","ett","rftt"]
Output: "wertf"

Approach: Compare adjacent words character by character to extract ordering constraints. Build a directed graph and run topological sort. If a cycle exists, return "".

Complexity: Time O(C) where C is total characters in input · Space O(U + min(U², N)) where U is unique chars

Follow-up: What if multiple valid orderings exist? Return any or all of them.


41. Longest Increasing Path in a Matrix Hard

OnsiteDFS · Memoization · GridLeetCode:&#35;329

Given an m x n integer matrix, return the length of the longest strictly increasing path.

Input:  matrix = [[9,9,4],[6,6,8],[2,1,1]]
Output: 4  (path: 1 → 2 → 6 → 9)

Approach: DFS with memoization. For each cell, DFS to all four neighbours that are strictly greater, caching results. No visited set needed — the strictly increasing constraint prevents cycles.

Complexity: Time O(m × n) · Space O(m × n)

Follow-up: What if diagonal moves are allowed?


42. Convert BST to Sorted Doubly Linked List Medium

OnsiteIn-order · Trees · Linked ListLeetCode:&#35;426

Convert a BST to a sorted circular doubly linked list in-place. The left pointer acts as prev, right pointer as next.

Input:  root = [4,2,5,1,3]
Output: Circular DLL: 1 ↔ 2 ↔ 3 ↔ 4 ↔ 5 (circular)

Approach: In-order DFS. Keep a prev pointer. At each node, link prev.right = node and node.left = prev. After traversal, connect head and tail to form a circle.

Complexity: Time O(n) · Space O(h)

Follow-up: Do the same for a general binary tree (not BST) — sort during conversion.


43. Continuous Subarray Sum Medium

OnsitePrefix Sum · Hashing · MathLeetCode:&#35;523

Given an integer array nums and an integer k, return true if there is a subarray of length at least 2 that sums to a multiple of k.

Input:  nums = [23,2,4,6,7], k = 6
Output: true  ([2,4] sums to 6)

Approach: Track running prefix sum mod k. If the same remainder appears at indices i and j where j - i >= 2, the subarray nums[i+1..j] is a multiple of k.

Complexity: Time O(n) · Space O(min(n, k))

Follow-up: Return the actual subarray.


44. Maximum Area of a Histogram Hard

OnsiteMonotonic StackLeetCode:&#35;84

Given an array of integers representing histogram bar heights, find the largest rectangular area that can be formed.

Input:  heights = [2,1,5,6,2,3]
Output: 10

Approach: Monotonic increasing stack. When a bar shorter than the stack top is found, pop and calculate area using the popped bar as height and current index as the right boundary.

Complexity: Time O(n) · Space O(n)

Follow-up: Maximal Rectangle in a matrix (LeetCode 85) — apply this solution row by row.


45. Best Time to Buy and Sell Stock III Hard

OnsiteDynamic Programming · GreedyLeetCode:&#35;123

You may complete at most two transactions. Find the maximum profit. You must sell before you buy again.

Input:  prices = [3,3,5,0,0,3,1,4]
Output: 6

Approach: Track four state variables: buy1, sell1, buy2, sell2. Update greedily — buy1 = max(buy1, -price), sell1 = max(sell1, buy1 + price), etc.

Complexity: Time O(n) · Space O(1)

Follow-up: At most k transactions (LeetCode 188). DP with k × 2 states.


46. Dot Product of Two Sparse Vectors Medium

OnsiteDesign · Hashing · Two PointersLeetCode:&#35;1570

Given two sparse vectors (most values are 0), design an efficient class to compute their dot product.

Input:  v1 = [1,0,0,2,3], v2 = [0,3,0,4,0]
Output: 8  (1×0 + 0×3 + 0×0 + 2×4 + 3×0 = 8)

Approach: Store only non-zero values as {index: value} hash maps. For dot product, iterate over the smaller map and multiply with the other map's value at the same index.

Complexity: Time O(n) init, O(L) per dot product where L is non-zero count · Space O(L)

Follow-up: If one vector is much sparser, use two-pointer on sorted index lists instead.


47. Validate Binary Search Tree Medium

OnsiteDFS · Trees · Bounds PropagationLeetCode:&#35;98

Given the root of a binary tree, determine if it is a valid BST.

Input:  root = [5,1,4,null,null,3,6]
Output: false  (right child 4 is less than root 5)

Approach: DFS with propagated bounds. At each node, check that its value falls within (min, max) bounds. Pass updated bounds to children — (min, node.val) for right, (node.val, max) for left.

Complexity: Time O(n) · Space O(h)

Follow-up: Recover BST (LeetCode 99) — two nodes are swapped, fix with O(1) space.


48. Palindrome Linked List Easy

OnsiteLinked List · Two Pointers · RecursionLeetCode:&#35;234

Check whether a singly linked list is a palindrome in O(n) time and O(1) space.

Input:  head = [1,2,2,1]
Output: true

Approach: Find the middle with slow/fast pointers, reverse the second half in-place, compare both halves. Optionally restore the list after comparison.

Complexity: Time O(n) · Space O(1)

Follow-up: What if the list is doubly linked? Use two pointers from both ends.


49. Set Matrix Zeroes Medium

OnsiteMatrix · In-placeLeetCode:&#35;73

If an element in an m x n matrix is 0, set its entire row and column to 0 in-place.

Input:  matrix = [[1,1,1],[1,0,1],[1,1,1]]
Output: [[1,0,1],[0,0,0],[1,0,1]]

Approach: Use the first row and first column as markers. First pass: if matrix[i][j] == 0, mark matrix[i][0] and matrix[0][j]. Second pass: zero out based on markers. Handle first row/column separately.

Complexity: Time O(m × n) · Space O(1)

Follow-up: What if you can use extra space? A simpler set-based approach works but costs O(m + n).


50. Letter Combinations of a Phone Number Medium

OnsiteBacktracking · RecursionLeetCode:&#35;17

Given a string of digits 2–9, return all possible letter combinations the number could represent (as on a telephone keypad).

Input:  digits = "23"
Output: ["ad","ae","af","bd","be","bf","cd","ce","cf"]

Approach: Backtracking. For each digit, iterate over its mapped letters. Recurse with the current combination and remaining digits. Add to result when combination length equals input length.

Complexity: Time O(4^n × n) in the worst case · Space O(n) recursion depth

Follow-up: Generate combinations in sorted order. Iterative BFS approach instead of recursion.


Meta Interview Tips

What Meta looks for:

  • Optimal solutions from the start — Meta engineers are known to ask "can you do better?" even after you give a correct answer. Always aim for the best time and space complexity.
  • Clean code — Variable naming, readability, and handling edge cases matter. Meta values production-quality code.
  • Communication — Think out loud. State your approach, complexity, and edge cases before coding.
  • No DP in phone screens — Multiple candidate reports confirm DP is rarely asked in the phone screen round. Focus on arrays, strings, trees, and graphs.

Behavioural (Meta uses STAR format):

  • "Tell me about a time you had a conflict with a teammate"
  • "Tell me about a time you pushed back on a decision"
  • "Tell me about your most impactful project"
  • Prepare 4–5 strong STAR stories covering leadership, conflict, technical decisions, and failures.

Recommended LeetCode study list: Filter problems tagged "Meta" on LeetCode and sort by frequency. Prioritise the top 50 — Binary Tree Right Side View, Minimum Remove to Make Valid Parentheses, Valid Palindrome II, and Merge Intervals appear in almost every report.