← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Interviewed at Meta for what seemed like a coding/algorithms round. The problem was around maximum profit, probably a stock prices variant. Not much else to go on from what I remember.

Questions Asked (1)

Q1

Given a list of stock prices over time, find the maximum profit you can make from a single buy and sell transaction.

Algorithms & Data Structures
Author's notes

Classic problem but I still fumbled the edge case where prices only go down.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints (e.g., single transaction, cannot sell before buying) and then propose an efficient O(n) time, O(1) space solution that tracks the minimum price seen so far and the maximum profit. Walk through the algorithm with a small example to demonstrate correctness and edge cases.

Pro tip: Mention that you would first confirm whether multiple transactions are allowed or if there are any constraints like transaction fees; this shows you think about real-world scenarios and avoid assumptions.

1. Clarify the problem

Ask questions to confirm the problem: single buy and sell, cannot sell before buying, and whether you can choose not to transact (profit 0).

2. Discuss brute force

Acknowledge that a brute force approach would check all pairs of buy and sell days, resulting in O(n^2) time, which is inefficient for large inputs.

3. Propose optimal solution

Explain the one-pass algorithm: iterate through prices, keep track of the minimum price seen so far, and compute the profit if sold at the current price, updating the maximum profit.

4. Walk through an example

Use a small array like [7,1,5,3,6,4] to illustrate how the algorithm works step by step, showing the min price and max profit updates.

5. Analyze complexity and edge cases

State that time complexity is O(n) and space is O(1). Discuss edge cases: empty array, decreasing prices (profit 0), and single element.

Key Points to Mention

  • Time complexity: O(n) single pass
  • Space complexity: O(1) constant extra space
  • Track minimum price and maximum profit
  • Cannot sell before buying
  • Return 0 if no profit possible
  • Handle edge cases: empty array, one element, decreasing prices

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