Category: String coding problemYou are building a scoring system for competitive ping-pong matches. Points are awarded one at a time to a player, and the score must be tracked...Input: String Output: Computed result
codingMediumVerified Question#2
2. Linked Topic Finder
Category: String coding problemYou are building a topic recommendation feature for a content platform. Topics are linked when they share readers in common. Given the reading data,...Input: List Output: Integer
codingMediumVerified Question#3
3. Distributed Log Timeline
Category: String coding problemYou are monitoring a distributed system consisting of multiple services, where each service generates event logs at specific timestamps. A JSON...Input: List Output: Computed result
codingHardVerified Question#4
4. Admin Permission System
Category: Trie-based coding problemYou are designing a system that tracks administrator privileges for an online platform using a time-ordered log of administration actions. Each log...Input: List Output: Computed result
codingHardVerified Question#5
5. Expense Ledger
Category: Graph coding problemA company's expense tracking database was lost. Fortunately, a complete historical log of all financial transactions was retained. Your task is to...Input: Graph (nodes and edges) Output: Computed result
codingHardVerified Question#6
6. Document Context Merger
Category: Trie-based coding problemA document review application maintains a history of entries where each entry is identified by a unique, strictly increasing integer id and...Input: List Output: Array
codingHardVerified Question#7
7. Org Chart Navigator
Category: Tree coding problemA company's reporting structure is described as a list relationships, where each element is a list of strings. The first string represents a...Input: Array of strings Output: Array
codingMediumsliding window#1
1. [Sliding Window] — Find the longest substring without repeating characters
Background: On Reddit, users often share content that can have overlapping themes and characters. It’s important to understand how to manage user input effectively, especially in features like comments or tags where uniqueness enhances the experience. Problem statement: Given a string s, return the length of the longest substring without repeating characters. A substring is defined as a contiguous sequence of characters in s. You must implement an efficient solution to handle potentially large strings common in user-generated content. Function/class signature:
def length_of_longest_substring(s: str) -> int:
Example 1:
Input: "abcabcbb"
Output: 3
Explanation: The answer is "abc", with the length of 3.
Example 2:
Input: "bbbbb"
Output: 1
Explanation: The answer is "b", with the length of 1.
Constraints:
0 <= s.length <= 50,000
s consists of English letters, digits, symbols and spaces.
codingMediumapi design#2
2. Coding — Rate Limiter for Multiple APIs
Background: As Reddit continues to grow, it becomes crucial to manage API requests effectively to prevent abuse and ensure fair resource utilization. A rate limiter is essential for APIs to handle request quotas based on user status and type of action taken on the platform. Problem statement: Implement a RateLimiter class that supports multiple APIs and handles different request quotas per user efficiently. Each user has a unique ID and can have different rate limits on different APIs. Your implementation should allow checking if a user can make a request to an API and register the request, updating the rate limit accordingly. Function/class signature:
Explanation: User 'user1' reached the request limit for 'api1'.
Constraints:
1 <= user_id <= 1000 (string)
1 <= api_name <= 100 (string)
The maximum number of requests a user can make in a period is modifiable when instantiating the RateLimiter class.
codingMediumheap#3
3. [Heap] — Implement a Priority Queue for Reddit Thread Management
Background: Reddit manages a large volume of posts and comments daily. A priority queue can efficiently organize threads based on user engagement or moderator review. This is critical for ensuring that popular or important discussions remain visible. Problem statement: Implement a PriorityQueue class that supports adding threads with a given priority and returning the thread with the highest priority. The class should implement the following operations:
add(thread: str, priority: int) -> None: Inserts a new thread with the specified priority into the priority queue.
poll() -> str: Removes and returns the thread with the highest priority. If two threads have the same priority, return the one that was added first.
peek() -> str: Returns the thread with the highest priority without removing it from the queue.
Explanation: "Post X" was added first, so it is returned despite the same priority.
Constraints:
Each thread will be a non-empty string of at most 100 characters.
The priority will be an integer between 1 and 100.
The number of operations will not exceed 10^4.
codingMediumgraph#4
4. [Graph] — Finding the Longest Path in a Subreddit
Background: Reddit has numerous subreddits with interconnected posts and comments that create a complex structure resembling a graph. Understanding these connections can enhance features like recommendation systems for users based on their interests. Problem statement: Given a directed acyclic graph that represents posts in a subreddit as nodes and comments as directed edges, write a function to find the longest path from the root node (the original post) to any other node (a comment). The path length is defined by the number of edges traversed. You must implement the function longest_path(graph: Dict[int, List[int]], start: int) -> int where graph is a dictionary where each key represents a node and the value is the list of nodes it points to. Function/class signature: