FastPrepGet Minimum Time for DNS Resolution
Problems/Get Minimum Time for DNS Resolution

Get Minimum Time for DNS Resolution

Walleye Capital logoWalleye Capital● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

A browser keeps a small DNS cache. Reading a web address from the cache is faster than asking a DNS server. You will simulate the cache and find how long each request takes.

The cache holds at most cache_size addresses. It starts empty. You get the requests in order. For each request:

  • If the address is in the cache, the request takes cache_time. The address then counts as the most recently used one.
  • If it is not in the cache, the request takes server_time. The address is added to the cache as the most recently used one. If the cache is now over its size, the address that was used longest ago is removed.

Return the time each request takes, in the same order as urls.

Complete the function getMinTime in the editor.

getMinTime has the following parameters:

  • int cache_size: the most addresses the cache can hold
  • int cache_time: the time to read an address from the cache
  • int server_time: the time to get an address from the DNS server
  • String[] urls: the addresses requested, in order

The function returns an int[]: the time of each request.

Function

getMinTime(cache_size: int, cache_time: int, server_time: int, urls: String[]) → int[]

Examples

Example 1

cache_size = 2cache_time = 3server_time = 5urls = ["www.google.com", "www.yahoo.com", "www.yahoo.com", "www.google.com", "www.yahoo.com", "www.yahoo.com", "www.coursera.com", "www.coursera.com"]return = [5, 5, 3, 3, 3, 3, 5, 3]

The cache holds 2 addresses. Hits cost 3 and misses cost 5.

  • www.google.com: not in the cache, so 5. The cache is [google].
  • www.yahoo.com: not in the cache, so 5. The cache is [google, yahoo].
  • www.yahoo.com: in the cache, so 3. The cache is [google, yahoo].
  • www.google.com: in the cache, so 3. Google is now the most recent: [yahoo, google].
  • www.yahoo.com: in the cache, so 3. The cache is [google, yahoo].
  • www.yahoo.com: in the cache, so 3.
  • www.coursera.com: not in the cache, so 5. The cache is full, so google, used longest ago, is removed: [yahoo, coursera].
  • www.coursera.com: in the cache, so 3.

The answer is [5, 5, 3, 3, 3, 3, 5, 3].

Constraints

  • 1 ≤ n ≤ 105, where n is the length of urls
  • 1 ≤ cache_size ≤ 100
  • 1 ≤ cache_time, server_time ≤ 109
  • 1 ≤ urls[i].length ≤ 20

More Walleye Capital interview questions

  • Minimum Testers to Find the Poisoned BottleOA · Seen Oct 2026
  • Posterior of a Poisson Rate After Observing a TotalOA · Seen Oct 2026
  • Squared Frobenius Norm of a Reflect-and-Stretch MapOA · Seen Oct 2026

Similar questions at other companies

  • Per-User Sliding-Window Rate LimiterPayPal · OAPayPal interview questions
  • Get Minimum Time for DNS Resolution (for Data Science Developer)IBM · OAIBM interview questions
  • Incident MonitorStripe · OAStripe interview questions
  • Named Async Task SchedulerAirwallex · OAAirwallex interview questions
  • Per-Client Sliding-Window Rate LimiterGeneral Motors · OA
  • Key-Value Locks with Waiting QueuesKlaviyo · OAKlaviyo interview questions
  • Truck Position SubscriberOptiver · OAOptiver interview questions
  • Capital Gains Tax from TradesArcesium · OAArcesium interview questions
  • Durable Work Queue OperationsOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Dynamic Least-Loaded Job DispatcherCresta · PHONE SCREENCresta interview questions
See Walleye Capital hiring insights
Saved
class Solution {
    public int[] getMinTime(int cache_size, int cache_time, int server_time, String[] urls) {
      // write your code here
    }

}
Checking account…