Level: Junior-Level
Round: Online Assessment · Type: Coding · Difficulty: 3/10 · Duration: 60 min · Interviewer: Friendly
Topics: Arrays
Location: San Francisco Bay Area
Interview date: 2025-07-09
Question: Given an integer array arr of length n, split it into two non-empty subarrays at some position i, where 1 <= i < n. For each possible split, calculate the number of distinct integers in the left and right subarrays, then add them together. Find the maximum value of this sum across all possible splits.
Question: Given an array responseTimes representing the response times of requests in a server log, batch delete requests according to the following rules: 1) Select the request with the current minimum response time; 2) Remove this request and its adjacent requests (one to the left and one to the right); 3) Repeat until the array is empty. Record each selected "minimum response time request" (do not record adjacent requests). Return the sum of the response times of all selected "minimum response time requests." If there are multiple minimum values, choose the leftmost one.
I encountered two problems during the online assessment.
The first problem involved finding the optimal way to split an array into two non-empty subarrays to maximize the sum of distinct elements in each subarray. I needed to iterate through all possible split positions and calculate the distinct element counts for the left and right subarrays.
The second problem simulated a server log processing scenario where requests are removed in batches based on their response times. I had to repeatedly find the minimum response time, remove the corresponding request and its neighbors, and accumulate the response times of the selected requests. Special attention was needed to handle edge cases and ensure the leftmost minimum is selected in case of ties.