← Meta Interview Insights

Meta·Software Engineer·Onsite - Coding / Algorithms·Intermediate

IntermediatePrefer not to say
Jul 2026

Summary

Meta software engineering interview with four coding tasks back to back. The problems ranged from string parsing to tree traversal to OOP design, which is a pretty wide spread for a single session. Felt like a gauntlet more than a conversation.

Questions Asked (4)

Q1

Given a string, determine whether it represents a valid decimal number, accounting for optional signs, decimal points, and scientific notation exponents.

Algorithms & Data Structures
Author's notes

This one is sneakier than it looks.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the exact rules for a valid decimal number (e.g., leading/trailing digits, exponent format) and then implement a deterministic finite automaton (DFA) that processes the string character by character. Alternatively, use a well-structured regex, but be prepared to explain the DFA states if asked to avoid regex. Walk through edge cases like '.', 'e', '+', and empty strings to validate the solution.

Pro tip: Meta interviewers value clean, bug-free code and strong communication. Before coding, explicitly list the edge cases you'll handle (e.g., '1.', '.1', '1e10', 'e10', '--1') and then test your solution against them—this shows thoroughness and reduces the chance of hidden bugs.

1. Clarify requirements and edge cases

Ask the interviewer to confirm the exact format: optional sign, integer part, optional decimal point and fraction, optional exponent with optional sign. List edge cases like empty string, '.', 'e', '1e', '1e+', '1e-', '1.', '.1', '+.1e-2'.

2. Choose an approach

Decide between a DFA (state machine) or regex. A DFA is more explicit and easier to reason about for edge cases; regex is concise but may be harder to debug. Mention both and pick one based on clarity.

3. Design the DFA states and transitions

Define states: start, sign, integer, dot, fraction, exponent, exponent sign, exponent integer, and accept/reject. Map each character to transitions, ensuring no invalid transitions (e.g., multiple dots, missing digits after exponent).

4. Implement and test

Write clean code with clear variable names. Test with a comprehensive set of valid and invalid strings, including edge cases from step 1. If time permits, discuss time/space complexity (O(n) time, O(1) space).

5. Review and optimize

Check for off-by-one errors and ensure all states are reachable. Consider if the solution can be simplified (e.g., using a single pass with flags). Be ready to explain why your solution is correct.

Key Points to Mention

  • Definition of a valid decimal number: optional sign, digits, optional decimal point, optional exponent with optional sign.
  • Edge cases: empty string, '.', 'e', '1e', '1e+', '1e-', '1.', '.1', '+.1e-2', leading/trailing whitespace (usually not allowed).
  • DFA states and transitions: start, sign, integer, dot, fraction, exponent, exponent sign, exponent integer, accept/reject.
  • Time and space complexity: O(n) time, O(1) space for DFA; regex may vary.
  • Alternative regex approach and its pitfalls (e.g., catastrophic backtracking, readability).
  • Testing strategy: walk through examples and edge cases, possibly using a table of inputs and expected outputs.

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

Q2

Given an array of daily asset prices, find the maximum profit from a single buy-sell trade, or return 0 if no profitable trade is possible.

Algorithms & Data Structures
Author's notes

Classic problem, nothing surprising.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem: single buy-sell, maximize profit, return 0 if none. Then propose a one-pass solution that tracks the minimum price seen so far and computes the maximum profit at each step. Discuss time and space complexity, and handle edge cases like empty array or strictly decreasing prices.

Pro tip: Mention that you can solve it in O(n) time and O(1) space, and that this is optimal since you must examine each price at least once. Also, note that returning 0 for no profit is a common convention, but confirm with the interviewer.

1. Clarify the problem

Confirm that you can only buy once and sell once, and that the buy must occur before the sell. Ask about edge cases: empty array, single element, all decreasing prices, and whether returning 0 is expected.

2. Discuss brute force

Mention the O(n^2) approach of checking every pair of buy and sell days to establish a baseline. This shows you understand the problem but also the need for optimization.

3. Propose optimal one-pass solution

Explain that you can iterate through the array once, keeping track of the minimum price seen so far and the maximum profit. At each price, update the minimum and compute the profit if sold today, updating the maximum profit.

4. Analyze complexity

State that the time complexity is O(n) and space complexity is O(1). Emphasize that this is optimal because you must look at each price at least once.

5. Handle edge cases and test

Walk through examples: empty array returns 0, single element returns 0, increasing prices yield profit, decreasing prices yield 0. Mention that you would test with these cases.

Key Points to Mention

  • Single buy-sell constraint and buy before sell
  • One-pass algorithm tracking minimum price and maximum profit
  • Time complexity O(n) and space complexity O(1)
  • Return 0 if no profit possible
  • Edge cases: empty array, single element, strictly decreasing prices
  • Optimality: cannot do better than O(n) time

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

Q3

Given a binary tree, return the values of the rightmost node at each depth, as seen from the right side.

Algorithms & Data Structures
Author's notes

BFS felt like the cleaner path here so I went with that, just grabbing the last element at each level.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem and edge cases, then present a level-order traversal (BFS) that records the last node at each level. Discuss complexity and compare with DFS alternatives, emphasizing correctness and efficiency.

Pro tip: Mention that BFS naturally captures the rightmost node per level, and that DFS can also work by prioritizing right children and tracking depth; this shows you understand trade-offs and can adapt to constraints.

1. Clarify the problem

Confirm the definition of 'rightmost node' and handle edge cases like an empty tree or a single node. Ask if the tree is binary and if values can be negative or duplicated.

2. Choose an approach

Decide between BFS (level-order) and DFS (pre-order with right-first). BFS is straightforward for level-by-level processing; DFS can be more space-efficient for skewed trees.

3. Implement the solution

For BFS: use a queue, process each level, and record the last node's value. For DFS: traverse right-first, track depth, and update the result when visiting a new depth.

4. Analyze complexity

State time complexity O(n) and space complexity O(w) for BFS (w = max width) or O(h) for DFS (h = height). Discuss trade-offs based on tree shape.

5. Test and validate

Walk through examples: empty tree, single node, perfect tree, skewed tree. Verify that the rightmost node at each depth is correctly captured.

Key Points to Mention

  • Level-order traversal (BFS) using a queue
  • Recording the last node at each level
  • DFS alternative with right-first traversal and depth tracking
  • Time complexity O(n) and space complexity O(w) or O(h)
  • Edge cases: empty tree, single node, skewed tree
  • Comparison of BFS vs DFS trade-offs

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

Q4

Design and implement a card deck library for a standard 52-card deck, including suits, ranks, reset, shuffle, draw, and a remaining count. Handle edge cases like drawing more cards than are left, and write unit tests for it.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The OOP part was fine but the unit tests tripped me up a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and defining the API, then design a clean class structure with clear responsibilities. Implement core operations with attention to edge cases, and write unit tests covering normal and boundary scenarios. Discuss trade-offs and potential extensions.

Pro tip: Demonstrate production-ready thinking by discussing thread safety, immutability, and how you would handle a multi-deck shoe for casino games. Also, mention that you would use a Fisher-Yates shuffle for unbiased randomization.

1. Clarify Requirements and API

Ask clarifying questions about expected behavior, such as whether the deck should be shuffled on reset, what exceptions to throw, and if multiple decks are needed. Define the public methods: reset, shuffle, draw, remaining.

2. Design the Data Model

Decide on representations for Suit and Rank (enums are ideal). Choose a data structure for the deck (e.g., List<Card> or array) and consider immutability of Card objects.

3. Implement Core Operations

Implement reset to initialize a full deck, shuffle using Fisher-Yates, draw to remove and return the top card, and remaining to return the count. Handle edge cases like drawing from an empty deck by throwing an exception or returning null.

4. Write Unit Tests

Write tests for: initial deck size, reset behavior, shuffle randomness (statistical test), draw reduces count, drawing all cards, and drawing beyond empty. Use a testing framework like JUnit.

5. Discuss Trade-offs and Extensions

Talk about thread safety (e.g., using synchronized or concurrent collections), performance considerations, and how to extend to multiple decks or jokers. Mention alternative shuffling algorithms and their trade-offs.

Key Points to Mention

  • Use enums for Suit and Rank to ensure type safety and avoid invalid values.
  • Implement Fisher-Yates shuffle for unbiased randomization.
  • Handle edge cases: drawing from empty deck, resetting after partial draw, and invalid inputs.
  • Write comprehensive unit tests covering normal, boundary, and error conditions.
  • Consider thread safety if the deck might be accessed concurrently.
  • Discuss design patterns like Iterator for drawing cards or Factory for creating decks.

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