Implement a LRU Cache
Design and implement a data structure for Least Recently Used (LRU) cache. It should support get and put operations in O(1) time.
Algorithm questions on sorting, searching, dynamic programming, graph algorithms, and complexity analysis.
6
Questions in database
Design and implement a data structure for Least Recently Used (LRU) cache. It should support get and put operations in O(1) time.
Given a binary tree, return the level order traversal of its nodes values (i.e., from left to right, level by level).
Given two sorted arrays nums1 and nums2, return the median of the two sorted arrays. The overall run time complexity should be O(log(m+n)).
Given the head of a singly linked list, reverse the list and return the reversed list. Implement both iterative and recursive solutions.
Implement a trie data structure with insert, search, and autocomplete functionality. Optimize for prefix searches.
Explain the concept of memoization. Implement a memoize function and discuss when memoization is beneficial vs harmful.