ByteDance software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
No verified questions yet for ByteDance.
LRUCachedef __init__(self, capacity: int): capacity.- Method Signature: def get(self, key: int) -> int:def put(self, key: int, value: int) -> None:LRUCache(2);cache.put(1, 1);cache.put(2, 2);cache.get(1);1;Example 2:cache.put(3, 3); // LRU key was 2, evicts key 2cache.get(2);-1;Constraints:capacity is a positive integer.get and put are guaranteed to be called on existing keys.UserPreferencesdef add_preference(self, category: str, preference: str) -> Nonedef get_preferences(self, category: str) -> List[str]def delete_preference(self, category: str, preference: str) -> Noneuser_prefs = UserPreferences() ; user_prefs.add_preference('music', 'rock')user_prefs.get_preferences('music')['rock']Example 2:user_prefs.add_preference('music', 'pop') ; user_prefs.get_preferences('music')['rock', 'pop']Constraints:1 <= len(category) <= 1001 <= len(preference) <= 100Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free