Design and implement a class KthLargest that, given an integer k and an initial list of integers, supports:
(
-
KthLargest(k, nums): constructor;
(
-
add(val): adds val to the data structure and returns the current k-th largest element. Achieve O(log k) time per insertion and O(k) space. Describe your data structures, handle duplicates, and analyze complexity.