Showing 3 of 163 questions
Transform a binary tree so that the original left-most leaf becomes the new root. The original root becomes a left child, and the original right child becomes the right child of the original root's parent.
#1. Binary Tree Upside Down
Design a data structure that supports insert, delete, and getRandom operations, all in average O(1) time. The getRandom method should return a random element from the current set of elements.
#2. Insert Delete GetRandom O(1)
You're given a nested list of integers where each integer has a depth. Calculate the weighted sum of all integers, where the weight is the depth of the integer from the bottom of the nested structure.
#3. Nested List Weight Sum II