1. LRU Cache Design Problem Statement Design a data structure that implements a Least Recently Used (LRU) cache. The cache should support the following operations: get(key) and put(key, value). When the cache reaches its capacity, it should invalidate the least recently used item before inserting a new item. Follow these constraints: get should return the value of the key if the key exists in the cache. Otherwise, it should return -1. put should update the value of the key if the key exists. Otherwise, it should insert the key-value pair. When the cache reaches its capacity, it should invalidate the least recently used item before inserting a new item. Example: LRUCache cache = new LRUCache(2); cache.put(1, 1); cache.put(2, 2); cache.get(1); // returns 1 cache.put(3, 3); // evicts key 2 cache.get(2); // returns -1 (not found) cache.put(4, 4); // evicts key 1 cache.get(1); // returns -1 (not found) cache.get(3); // returns 3 cache.get(4); // returns 4
2. Given a string containing parentheses, curly brackets, and square brackets, determine if the string is valid.
3. Explain C++ pointers, addressing, and debugging.
4. Given a singly linked list, determine if it is a palindrome.
5. How does a packet travel in a switch network?
Browse through a variety of job opportunities tailored to your skills and preferences. Filter by location, experience, salary, and more to find your perfect fit.
We have sent an OTP to your contact. Please enter it below to verify.