Showing 3 of 579 questions
Design a data structure that acts as a Least Recently Used (LRU) cache. Implement methods to get and put key-value pairs, evicting the least recently used entry when the cache is full.
#1. LRU Cache
You're given daily stock prices. Find the maximum profit you can make by buying and selling the stock once. You must buy before you sell.
#2. Best Time to Buy and Sell Stock
Find the k most frequent elements in a given array of numbers. Return the top k elements based on their frequency.
#3. Top K Frequent Elements