×

# Approach for Cooking Game

 1 Please share your approach for cooking game in February cook-off. asked 20 Feb '17, 00:11 53●4 accept rate: 0%

 3 put arr[1] = 1 , if arr[i] = x , then put arr[i - 1] = x - 1 , arr[i - 2] = x - 2 ... till it becomes 1 , now answer is just 2 ^ (count of -1's). answered 20 Feb '17, 00:23 1.0k●1●12 accept rate: 4%
 0 First of all for all i's(stating from i=n) such that a[i+1]>1, set a[i]=a[i+1]-1 if it is -1 or a[i+1]-1.else array is invalid. Second checked if a[i]=1or-1 if it is anything else array is invalid.set a[i]=1 now every a[i]=-1 can be changed to a[i-1]+1 or 1.(2 possibilities for every such i) so final answer is 2^x.(x=no. of i's such that a[i]=-1). if array is invalid answer is 0. answered 20 Feb '17, 00:30 21●2 accept rate: 0%
 0 First of all for all i's such that a[i+1]>1, set a[i]=a[i+1]-1 if it is -1 or a[i+1]-1.else array is invalid. Second checked if a[i]=1or-1 if it is anything else array is invalid.set a[i]=1 now every a[i]=-1 can be changed to a[i-1]+1 or 1.(2 possibilities for every such i) so final answer is 2^x.(x=no. of i's such that a[i]=-1). if array is invalid answer is 0. answered 20 Feb '17, 00:30 21●2 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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:11

question was seen: 329 times

last updated: 20 Feb '17, 00:32