One Block COding question - Solved
One block
You are working in the resource distribution team of your company. A One block is a block of data having exactly one resource which has value 1. You are given an array Arr containing Nresource values.
What is the number of ways to divide the array into continuous blocks such that each block is One block.
NOTE - If we cannot form a block with One block, then output 0
Function description
Complete the function OneBlock() This function takes the following 2 parameters and returns the required answer.
. N: Represents the number of resources
. Ar Represents the value of resources
Input format for custom testing
Note: Use this input format if you are testing against custom input or writing code in a language where we don't provide boilerplate code
. The first line contains an integer N denoting the number of resources.
. The second line contains N space-separated integers denoting the value of resources.
Output format
Return the number of ways to divide the array into continuous blocks such that each block is One block.
Constraints
1 < N β€ 100
Sample input
Sample output