One Block COding question - Solved

8 Live
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

Asked in: SHARECHAT

Image of the Question

Question Image Question Image Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| You are given a board of size M Γ— N where each cell can be either empty ('O') o… |
| Undirected Coloured Graph Shortest Path You are given an undirected weight… |
| Village Voyage A computer game "Village Voyage" has N villages (labeled 1 to… |
| Academic Decathlon Students are being selected for an academic decathlon tea… |
| Sum of Arrays Given two arrays each of length n, arr1 and arr2, in one opera… |
| Count Swaps During Custom Sorting Analyze the efficiency of the following so… |