Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9269585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:09:39+00:00 2026-06-18T15:09:39+00:00

Since the contest is now over I would like to ask about this question.

  • 0

Since the contest is now over I would like to ask about this question. I’ve been really struggling with this question for the past three days because actually I’m not able to understand it.

Here’s the question:
Find the min Facebook Hacker Cup 2013

Here’s the site where I found a solution for this question:
Solutions

What I’m not able to understand is the following part:

Although these first K values could be anything, we can make some useful observations
about the contents of the array after the initial K elements:

  1. Every element will be between 0 and K (inclusive) by the pigeonhole principle.
  2. Consequently, every window of K + 1 consecutive elements will contain each value between 0 and K exactly once (i.e. it contains a permutation of the integers 0 through K).
  3. Consequently, for i > 2K: M[i] = M[i – (K + 1)].

Though I’m able to understand the second and third points iff the first is true. The first one is actually troubling me. Why do the elements have to be between 0 and K why can’t all of them just be the minimum non-negative integer which is not present in the initial K elements.

For eg:
For the following test case:

1

46 18

7 11 9 46

The first K elements are:

[7, 40, 35, 26, 19, 34, 15, 36, 37, 2, 31, 28, 41, 0, 9, 16, 1, 20]

Now why do the rest of the elements have to be between 0 and 18, when I have elements which are more than 18 in my previous K elements.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:09:40+00:00Added an answer on June 18, 2026 at 3:09 pm

    Imagine you have K numbers {a0,a1,a2...a(k-1)}, now you want to find the first non-negative number that is not among them. Can it be more than K? Well if that is true, then all the numbers {0,1,...K} are present in the above set and that is K+1 numbers should be present in the above set, which consists of K numbers. This is not possible and hense a contradiction with the assumption that the new number is more than K. So on each step the next number you add will be in the range [0,K] and thus on the K+1 step all the last K+1 numbers will be in that step and thus be different numbers in that range.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been scratching my head over this for a long time now and searched
First off, I know this has been discussed over and over again . But
Since I've been experimenting with jQuery for just a few days now, a few
I have some code that has been working since it's beginning, well over a
Since now I have only used plugin for editing and the way I use
Since I have no errors I don't know if this is the right place
I have a WCF that is in use now for over a year, coded
So I've been struggling on a rather weird problem. I've tried everything from display:inline-block
I would like to be able to output a timeline containing the number of
I'm new to Python and Django and have over the past few weeks managed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.