← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Apr 2026

Summary

Meta SWE coding round with a string manipulation problem. Pretty standard stuff but the O(n) constraint means you can't just brute force it.

Questions Asked (1)

Q1

Given an ASCII string, find the index of the first character that appears exactly once. Return -1 if no such character exists.

Algorithms & Data Structures
Author's notes

Classic frequency count problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem constraints (e.g., ASCII, case sensitivity) and propose a two-pass solution using a frequency array or hash map. First pass counts occurrences, second pass finds the first character with count 1, returning its index or -1.

Pro tip: Mention that since the string is ASCII, a fixed-size array of 256 integers is more efficient than a hash map, and explicitly state the O(n) time and O(1) space complexity.

1. Clarify requirements and constraints

Ask about character set (ASCII vs Unicode), case sensitivity, and whether the string can be empty. Confirm the expected return value for no unique character.

2. Choose data structure

Decide between a fixed-size array (for ASCII) or a hash map (for general characters). Explain the trade-offs in time and space.

3. First pass: count frequencies

Iterate through the string once, incrementing the count for each character in the chosen data structure.

4. Second pass: find first unique

Iterate through the string again, checking the count for each character. Return the index of the first character with count 1.

5. Handle no unique character

If the second pass completes without finding a unique character, return -1.

Key Points to Mention

  • Time complexity: O(n) for two passes over the string.
  • Space complexity: O(1) if using a fixed-size array for ASCII (256 characters).
  • Alternative approach: use a hash map for Unicode or if character set is unknown.
  • Edge cases: empty string, all characters repeated, unique character at the end.
  • Optimization: early termination in second pass is not possible because we need the first unique.
  • Trade-off: using an array is faster and more memory-efficient for ASCII, but less flexible.

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