ByteDance logo

ByteDance Software Engineer System Design Questions

31 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.

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.

system design Senior caching #1

1. [OA] LRU Cache — Implement the caching layer for ByteDance's real-time content delivery

For efficient performance on ByteDance's content delivery platform, we need a system that caches frequently accessed user data and drops the least recently used data when the capacity is exceeded.
You are to implement an LRU (Least Recently Used) cache.
Class Name: LRUCache
  • Method Signature: def __init__(self, capacity: int):

  • Initializes the LRU cache with positive size capacity.


  • Method Signature: def get(self, key: int) -> int:

  • Returns the value of the key if the key exists, otherwise returns -1.


  • Method Signature: def put(self, key: int, value: int) -> None:

  • Update or insert the value if the key is not already present. When the cache reaches its capacity, it should invalidate the least recently used item before inserting a new item.


Example 1:
Input: LRUCache(2);
cache.put(1, 1);
cache.put(2, 2);
cache.get(1);
Output: 1;
Example 2:
Input: cache.put(3, 3); // LRU key was 2, evicts key 2
cache.get(2);
Output: -1;
Constraints:
  • capacity is a positive integer.

  • All keys and values are in the range of 1 to 10000.

  • The functions get and put are guaranteed to be called on existing keys.

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