You are not logged in. Please login at to post your questions!


Doubt in Cooking Game

The question quotes: "Now Chef is asking you to count the number of ways to fill the missing numbers (ie. the -1s) of the array with level numbers, so that it corresponds to a valid game. Since the answer can be large, output it modulo 109+7."

So, if there is no missing number the count is zero. But the solutions getting accepted outputs answer 1. Why?

Question link:

asked 20 Feb '17, 00:55

rishi_07's gravatar image

accept rate: 20%

edited 22 Feb '17, 14:08

admin's gravatar image

0★admin ♦♦

Actually the count is 1, because not substituting any -1 anywhere where there are no -1s to substitute is a valid way and the only one. This is similar to the fact that the number of ways of ordering 0 objects is 1, in other words $0!=1$. Or that the number of ways to choose 0 objects from a collection of n is 1, which means ${n \choose 0} = 1$.


answered 20 Feb '17, 01:10

meooow's gravatar image

6★meooow ♦
accept rate: 48%

edited 20 Feb '17, 01:12

unless it's invalid then the answer is 0

(20 Feb '17, 01:12) kingofnumbers ♦6★

Yes of course :)

(20 Feb '17, 01:15) meooow ♦6★

@kingofnumbers @meooow : The problem statement stated the rules for playing the game as "Chef will start in level 1 and whenever Chef passes a level in this game he will advance to the next level, but if Chef fails, he will return to level 1." How come then, the answer is 0 for any test case. I understand that if the sequence is invalid the solution would be 0, but as the statement clearly states the rules, and it is not mentioned anywhere that chef's memory can be wrong or he can play an invalid game, is the assumption of a valid game wrong? Please correct me if I am wrong.

(20 Feb '17, 02:44) rishabh.jain91964★


don't assume anything that is not mentioned in "constraints" section

(20 Feb '17, 02:49) kingofnumbers ♦6★
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 20 Feb '17, 00:55

question was seen: 425 times

last updated: 22 Feb '17, 14:08