We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Data Structures
  3. Queues
  4. Queries with Fixed Length
  5. Discussions

Queries with Fixed Length

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • chenhusjtu
    9 months ago+ 0 comments

    why is complexity O( QN)? i think it's O(N). I guess the worst case is 5 4 3 2 1 5 4 3 2 1 5 4 3 2 1 ... where Q=5. Only at 5, we need 4 comparisions, because 4 3 2 1 are in the queue, but we only have N/Q 5, and thus (Q-1)* N/Q is about N. What do you think?

    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy