← TikTok Interview Insights

TikTok·Software Engineer·Technical Phone Screen·Junior

JuniorPrefer not to say
Jul 2026Remote

Summary

Interviewed for an SRE intern role at TikTok and got hit with a LeetCode hard in a 30-minute live coding session. First ever technical interview and it did not go well.

Questions Asked (1)

Q1

Implement a basic calculator that supports addition, subtraction, multiplication, division, and nested parentheses (LeetCode 772 style).

Algorithms & Data Structures
Author's notes

I froze.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a stack-based approach to handle nested parentheses and operator precedence. Iterate through the expression, maintaining a current result and sign, and push the current result and sign onto a stack when encountering '('. When encountering ')', pop and combine. This elegantly handles nested parentheses without explicit recursion.

Pro tip: Clarify constraints upfront (e.g., integer division truncation, spaces, unary operators) and mention that you'll handle edge cases like division by zero or empty input. This shows attention to detail and prevents misunderstandings.

1. Clarify requirements and edge cases

Ask about integer vs floating-point division, handling of spaces, unary operators, and invalid expressions. Confirm the expected output format.

2. Choose data structures and algorithm

Decide between stack-based iterative approach or recursive descent parser. For LeetCode 772, a stack is simpler and avoids recursion depth issues.

3. Implement the stack-based evaluation

Iterate through characters, maintaining current number, result, and sign. On '(', push current result and sign, reset them. On ')', pop and combine. Apply operators with precedence.

4. Test with examples and edge cases

Walk through examples like '1+2*3', '(1+(4+5+2)-3)+(6+8)', and edge cases like negative numbers, division truncation, and nested parentheses.

5. Analyze complexity and discuss optimizations

State time and space complexity (O(n) time, O(n) space for stack). Mention potential optimizations or alternative approaches like recursive descent.

Key Points to Mention

  • Stack-based evaluation to handle nested parentheses and operator precedence
  • Handling of multi-digit numbers and unary operators (e.g., negative numbers)
  • Operator precedence: multiplication and division before addition and subtraction
  • Time and space complexity: O(n) time, O(n) space
  • Edge cases: division by zero, empty string, spaces, and integer division truncation
  • Comparison with recursive descent parser as an alternative approach

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