3rd Round:
SQL: Database Schema:
The student table contains:
ID (INTEGER) - unique identifier, primary key
NAME (STRING) - student's name
The backlog table maintains records of active backlogs for each student.
Task:
Write a SQL query to retrieve the names of students who have at least one active backlog. The results should be:
Displayed in ascending order by name
Formatted with a column header: NAME
Important Note: Multiple students may share the same name but have different IDs, so the query needs to account for this possibility.
The challenge requires joining or filtering data from both tables to identify students with active backlogs and returning their names in sorted order.
2. DSA: Rate Limiter Problem
Implement a gateway service that controls incoming request rates. In each second i, the gateway receives a request from domain request[i].
Rate Limits:
Maximum 2 successful requests per domain within 5 seconds
Maximum 5 successful requests per domain within 30 seconds
Return:
"{status: 200, message: OK}" if request can be processed
"{status: 429, message: Too many requests}" if limit exceeded
Example:
Given requests from domains: www.xyz.com, www.abc.com, www.xyz.com, www.pqr.com, www.abc.com, www.xyz.com, www.xyz.com, www.abc.com, www.xyz.com
The table shows at time 0, request from www.xyz.com is accepted (True), and at time 1, request from www.abc.com is also accepted (True).
3. More related to low level design and unit testing. Like how to improved the code here, is the JUnit test is okay,rewrite it.