My first instinct was just a sorted list with bisect.insort, which gets you O(log n) insert but O(1) findLargest since you can index directly.
Clarify requirements and constraints first, then propose a balanced BST augmented with subtree sizes to support O(log n) insert and O(log n) findLargest. Discuss trade-offs with other approaches like heaps or Fenwick trees, and optimize findLargest by maintaining order statistics.
Pro tip: Mention that Google often values clean, scalable solutions; emphasize that the augmented BST approach is optimal for both operations and discuss how to handle duplicates by storing counts.
Ask about constraints: expected number of operations, value range, memory limits, and whether findLargest is called frequently. Confirm that duplicates are allowed and 0-indexed k-th largest means k=0 returns the maximum.
Consider options: sorted array (O(n) insert), heap (O(log n) insert but O(k log n) findLargest), balanced BST with subtree sizes (O(log n) both), Fenwick tree over compressed values (O(log n) both). Evaluate trade-offs.
Choose an augmented balanced BST (e.g., Red-Black or AVL) where each node stores the size of its subtree. This allows finding the k-th largest in O(log n) by traversing from the root.
Explain insert: standard BST insert, update subtree sizes on the path. Explain findLargest(k): traverse right subtree first, using sizes to skip subtrees, similar to finding k-th smallest but reversed.
State time complexity: O(log n) for both operations. Space: O(n). Handle duplicates by storing a count per node. Discuss edge cases: k out of bounds, empty tree, and large k.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.