ByteDance logo

ByteDance Software Engineer Coding Questions

33 practice questions for ByteDance Software Engineer interviews

ByteDance software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

All Roles Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer

No verified questions yet for ByteDance.

coding Hard graph #1

1. [OA] Depth-First Search — Find the most relevant user connections in ByteDance's social platform

In ByteDance's social networking site, we need to model user relationships and find the most relevant connections for a given user in a depth-first manner.
You are to implement a function that takes the connections of users and a target user, returning all relevant connections.
Method Signature: 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.
- Returns a list of user IDs that are reachable from the target user.
Example 1:
Input: connections = {'a': ['b', 'c'], 'b': ['d'], 'c': ['e'], 'd': [], 'e': []} and user = 'a'
Output: ['b', 'c', 'd', 'e']
Explanation: From user 'a', you can reach 'b', 'c', 'd', and 'e'.
Example 2:
Input: connections = {'x': ['y'], 'y': ['z'], 'z': []} and user = 'x'
Output: ['y', 'z']
Explanation: User 'x' can reach 'y' and 'z'.
Constraints:
- 1 <= len(connections) <= 10^4
- Each user ID has at most 100 characters.
coding Hard sliding window #2

2. [OA] Sliding Window — Implement a user feed for ByteDance's content platform

In the dynamic environment of ByteDance's content platform, we need to efficiently generate a user feed that displays trending content based on real-time user interactions.
You are to implement a function that takes a list of user interactions (likes or comments) and generates a list of trending content using a sliding window approach.
Method Signature: def 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.
- Returns a List of strings containing the IDs of the trending content items.
Example 1:
Input: interactions = ['a', 'b', 'a', 'c', 'b', 'a']
Output: ['a', 'b', 'c']
Explanation: Item 'a' is interacted with 3 times, 'b' 2 times, and 'c' 1 time.
Example 2:
Input: interactions = ['x', 'y', 'y', 'x', 'x', 'z', 'y']
Output: ['x', 'y', 'z']
Explanation: 'x' has 3 interactions, 'y' has 3, and 'z' has 1.
Constraints:
- 1 <= len(interactions) <= 10^4
- 1 <= n <= 100
- interactions[i] is a string with length 1 to 100.

Related ByteDance Software Engineer interview prep

Start practicing ByteDance questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free