silenttkillerr's blog

By silenttkillerr, history, 19 months ago, In English

This Question logic implemenation is easy , but as test case is very large so it is not able to pass in 2 seconds even after Meomizing the answer.

Images :

https://imgur.com/gallery/anvdek1

  • Vote: I like it
  • -25
  • Vote: I do not like it

»
19 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by silenttkillerr (previous revision, new revision, compare).

»
19 months ago, # |
  Vote: I like it 0 Vote: I do not like it

This problem can not be solved.

»
19 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by silenttkillerr (previous revision, new revision, compare).

»
19 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by silenttkillerr (previous revision, new revision, compare).

»
19 months ago, # |
  Vote: I like it 0 Vote: I do not like it

There are up to 2 parts of each sequence of events 1) ball is passed around without entering a cycle 2) eventually the ball will enter into a cycle for large number of passes. Proof: if there are more passes that people, then some person must receive the ball more than once by pigeon hole principle.

You need to handle both cases elegantly. The cycle part needs to be handled with modular arithmetics.

  • »
    »
    19 months ago, # ^ |
    Rev. 3   Vote: I like it +3 Vote: I do not like it

    so we just figure out the cycle size and check if the number of passes in the questions is below that or above that and give the ans using modular arithmetics right?

    • »
      »
      »
      19 months ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      Yep, you got it! Also note that the cycle may not start on the first person so you need to handle that too.

      • »
        »
        »
        »
        19 months ago, # ^ |
          Vote: I like it +3 Vote: I do not like it

        i don't get how these questions seemed so damn hard when i was giving company online assessments, but now they seems like a breeze lol