ByteDance software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
No verified questions yet for ByteDance.
def find_relevant_connections(connections: Dict[str, List[str]], user: str) -> List[str]:connections: a dictionary where keys are user IDs and values are lists of user IDs representing friendships.user: a string representing the target user's ID.connections = {'a': ['b', 'c'], 'b': ['d'], 'c': ['e'], 'd': [], 'e': []} and user = 'a'['b', 'c', 'd', 'e']connections = {'x': ['y'], 'y': ['z'], 'z': []} and user = 'x'['y', 'z']1 <= len(connections) <= 10^4def generate_trending_feed(interactions: List[str], n: int) -> List[str]:interactions: a List of strings representing the IDs of content interacted with by a user.n: an integer representing the number of trending content items to return.List of strings containing the IDs of the trending content items.Example 1:interactions = ['a', 'b', 'a', 'c', 'b', 'a']['a', 'b', 'c']interactions = ['x', 'y', 'y', 'x', 'x', 'z', 'y']['x', 'y', 'z']1 <= len(interactions) <= 10^41 <= n <= 100interactions[i] is a string with length 1 to 100.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