FastPrepQuery Type Frequency Window
Problems/Query Type Frequency Window

Query Type Frequency Window

IBM logoIBM● MediumINTERNOA

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

You are given n query logs, where each log entry includes:

  • timestamps[i]: the time of the query in seconds (sorted in non-decreasing order)
  • queryTypes[i]: the query type recorded at that time

A query type should be included in the result if:

  • There exists at least one 600-second window in which that query type appears at least threshold times.

Return:

  • All query types that meet this condition, sorted in increasing (lexicographical) order
  • An empty array if none qualify

Function

findFrequentQueryTypes(timestamps: int[], queryTypes: String[], threshold: int) → String[]

Examples

Example 1

timestamps = [100, 150, 200, 250, 700]queryTypes = ["Q1", "Q1", "Q1", "Q2", "Q1"]threshold = 2return = ["Q1"]

The table below shows the time window during which the query type appeared at least threshold times, along with its corresponding frequency count:

Query Types Frequency Table

Time WindowQuery TypeFrequency Count
[101, 700]Q13

The query type "Q1" occurs 3 times between timestamps 101 and 700, which is within a 600-second window. Since threshold = 2, "Q1" exceeds the required frequency. Hence, the answer is ["Q1"].

Constraints

  • 1 <= n <= 2 * 10^5
  • 1 <= threshold <= 2 * 10^5
  • 1 <= length of queryTypes[i] <= 10

More IBM Online Assessment questions

  • Missing IntervalsOA · Seen Nov 2026
  • Count Peaks and ValleysOA · Seen Nov 2026
  • Last Object Exit TimeOA · Seen Nov 2026
  • Count Strictly Increasing Contiguous WindowsOA · Seen Nov 2026
  • Total Each Letter's Count in an Encoded StringOA · Seen Nov 2026
  • Count Servers With No Requests in a Time WindowOA · Seen Nov 2026
  • Maximum Easy Tasks After RearrangingOA · Seen Nov 2026
  • Tree Pythagorean TriplesOA · Seen Oct 2026
  • Minimum Power-of-Two Removal OperationsOA · Seen Oct 2026
  • Maximum Compatible Time WindowsOA · Seen Oct 2026

Similar questions at other companies

  • Earliest Hour with Frequent Badge AccessIntuit · OAIntuit interview questions
  • Count Zero Request ServersSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Sliding-Window Frequency SnapshotsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Detect Security Attacks from Network LogsFireworks AI · PHONE SCREEN
  • Smallest Range Covering Elements from K ListsSnap Inc. · PHONE SCREENSnap Inc. interview questions
  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN
  • Count Belt Sections With K Fruit Pairs (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
  • Minimum Distinct Prefix CostChubb · OAChubb interview questions
  • Count Redundant File BackupsGoldman Sachs · OAGoldman Sachs interview questions

IBM interview experiences

  • IBM Full-Time SWE OA Questions: 1 Experience
  • IBM Software Intern Résumé Rounds: 2 Experiences (Part 3 of 3)
  • IBM Intern Blitz Interviews: 23 Experiences (Part 2 of 3)
  • IBM Software Intern Interviews: 44 Experiences (Part 1 of 3)
  • IBM Software Intern Interview Questions: 15 Experiences
All IBM interview questionsSee IBM hiring insights
Saved
class Solution {
    public String[] findFrequentQueryTypes(int[] timestamps, String[] queryTypes, int threshold) {
      // write your code here
    }
}
Checking account…