← HarveyAI Interview Insights

HarveyAI·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Live coding round at HarveyAI for a software engineer role. The session was centered on a tree-related problem and string manipulation under real time pressure, with the interviewer pushing hard on time complexity throughout.

Questions Asked (1)

Q1

Solve a lowest common ancestor problem on a binary search tree, then extend it to handle string editing via simulated mouse interactions. Time complexity analysis required throughout.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The base LCA part was fine, I know that problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem and constraints, then solve the BST LCA using the BST property with O(h) time and O(1) space. For the string editing extension, model the mouse interactions as a state machine and analyze the time complexity of each operation, considering trade-offs between different data structures.

Pro tip: Explicitly state your assumptions about the mouse interaction model (e.g., click positions, drag behavior) and discuss how you would test edge cases like empty strings or invalid clicks. This shows you think about real-world robustness, not just the algorithm.

1. Clarify requirements and constraints

Ask questions to understand the BST structure (e.g., are duplicates allowed?), the string editing operations (e.g., what mouse events are simulated?), and any performance requirements. Confirm the expected input/output format.

2. Solve BST LCA

Explain the iterative approach: traverse from root, moving left if both nodes are smaller, right if both are larger, else return current node. State time complexity O(h) and space O(1).

3. Model string editing via mouse

Define a state machine for mouse interactions (e.g., click to position cursor, drag to select, type to replace). Map each interaction to string operations and choose an appropriate data structure (e.g., gap buffer, rope, or simple string with indices).

4. Analyze time complexity of each operation

For each mouse event, derive the time complexity based on the chosen data structure. Compare trade-offs (e.g., O(n) for simple string vs O(log n) for balanced tree) and justify your choice.

5. Discuss edge cases and testing

Mention handling empty strings, invalid clicks, overlapping selections, and performance under repeated operations. Suggest unit tests for both problems.

Key Points to Mention

  • BST property: left subtree values < node < right subtree values, enabling O(h) LCA.
  • Time complexity of BST LCA: O(h) where h is height; O(log n) for balanced BST, O(n) worst-case.
  • Mouse interaction model: click to set cursor, drag to select, typing to insert/replace.
  • Data structure trade-offs for string editing: simple string (O(n) insert/delete), gap buffer (amortized O(1) local edits), rope (O(log n) split/concat).
  • Complexity analysis for string operations: e.g., insertion at cursor O(1) with gap buffer, but O(n) with simple string.
  • Edge cases: empty tree, one node is ancestor of other, empty string, selection beyond bounds, rapid repeated clicks.

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