OpenAI software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
System Design Questions - OpenAI A collection of commonly asked system design questions from OpenAI interviews.
Input: Given inputClass Definition
MedianFinder should implement the following methods:addNum(num: int) -> None: Adds a number to the data structure.findMedian() -> float: Returns the median of all added numbers.Example 1:
medianFinder = MedianFinder(); medianFinder.addNum(1); medianFinder.addNum(2); medianFinder.findMedian()1.5Example 2:
medianFinder.addNum(3); medianFinder.findMedian()2Constraints:
-10^5 <= num <= 10^51,000,000 calls to addNum and findMedian.Class Definition
LRUCache should implement the following methods:get(key: int) -> int: Returns the value of the key if the key exists, otherwise returns -1.put(key: int, value: int) -> None: Updates the value of the key if the key exists existing and moves the key to the front of the cache. Otherwise, it adds the key/value pair to the cache.Example 1:
cache = LRUCache(2); cache.put(1, 1); cache.put(2, 2); cache.get(1)1Example 2:
cache.put(3, 3); cache.get(2)-1Constraints:
1 and 1000.Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free