FastPrepTop-K URLs Overall and in the Last 24 Hours
Problems/Top-K URLs Overall and in the Last 24 Hours

Top-K URLs Overall and in the Last 24 Hours

Oracle logoOracle● MediumFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Oracle phone screen. The report gives both top-K views, one overall and one for the last 24 hours, and a setting with limited memory. It does not say exactly how the window and ties work. Our version is about 94% the same as the reported question.

You are given access-log records in parallel arrays. Record i contains URL urls[i] and Unix-second timestamp timestamps[i].

Return two ranked URL lists:

  1. the top k URLs across all records;
  2. the top k URLs whose timestamps are in the inclusive interval [queryTime - 86400, queryTime].

Rank a URL with more accesses first. Break equal-frequency ties by lexicographically smaller URL. If a group contains fewer than k distinct URLs, return all of them. The result is a two-row string matrix in overall-then-recent order.

Function

topKUrls(urls: String[], timestamps: long[], queryTime: long, k: int) → String[][]

Examples

Example 1

urls = ["old","old","old","new","new","edge"]timestamps = [1,2,3,200000,199999,113600]queryTime = 200000k = 2return = [["old","new"],["new","edge"]]

Overall, old appears three times and new twice. Only new and edge fall in the inclusive recent window.

Example 2

urls = ["b","a","c"]timestamps = [10,10,10]queryTime = 10k = 5return = [["a","b","c"],["a","b","c"]]

All frequencies tie, so lexicographic order decides; fewer than k distinct URLs are returned.

Constraints

  • 1 <= urls.length = timestamps.length <= 2 * 10^5
  • 1 <= k <= 10^5
  • Each URL is a non-empty lowercase path of length at most 100.
  • 0 <= timestamps[i] <= queryTime <= 10^12

More Oracle Phone Screen questions

  • Remove Parentheses from a Plus-Minus ExpressionPHONE SCREEN · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · Seen Oct 2026
  • Shortest Window by Distinct-Value SumPHONE SCREEN · Seen Oct 2026
  • Detect a Cycle in a Directed GraphPHONE SCREEN · Seen Oct 2026
  • Time-Based Key-Value StorePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Remove Adjacent Duplicates in String IIPHONE SCREEN · Seen Oct 2026
  • Sum Root-to-Leaf Binary NumbersPHONE SCREEN · Seen Oct 2026
  • Longest All-Present Attendance StreakPHONE SCREEN · Seen Oct 2026
  • Next PermutationPHONE SCREEN · Seen Sep 2026
  • Valid ParenthesesPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Travelers per Consecutive City TripletUber · ONSITE INTERVIEWUber interview questions
  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Group AnagramsAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Filter, Sort, and Deduplicate Scheduled TasksRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Count Zero Request ServersSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Longest Consecutive SequenceJP Morgan Chase · PHONE SCREENJP Morgan Chase interview questions
  • Top K Frequent Elements with a Recency TiebreakSwiggy · PHONE SCREEN
  • Pins Violation Log QueriesPinterest · PHONE SCREENPinterest interview questions
  • Group AnagramsWorkday · PHONE SCREEN

Oracle interview experiences

  • Oracle SWE Onsite Interview Experience: 1 Experience
All Oracle interview questionsSee Oracle hiring insights
Saved
class Solution {
    public String[][] topKUrls(String[] urls, long[] timestamps, long queryTime, int k) {
        // Write your code here.
    }
}
Checking account…