Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1 3 Max. score: 2 0 . 0 0 One block You are working in the resource distribution team of your company. A One

Question 13
Max. score: 20.00
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 N resource 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 O.
Function description
Complete the function OneBlock(). This function takes the following 2
parameters and returns the required answer:
N : Represents the number of resources
Arr. 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
Print the number of ways to divide the array into continuous blocks such that : Programming question
:' :
38min08sec
Explanation
Given
N=3
Arr =[0,1,0]
Approach
There is exactly one resource that has the value of 1. Hence, the number of ways is 1.
Note:
Your code must be able to print the sample output from the provided sample input.
However, your code is run against multiple hidden test cases. Therefore, your code must
pass these hidden test cases to solve the problem statement.
Limits
Time Limit: 1.0sec(s) for each input file
Memory Limit: 256MB
Source Limit: 1024 KB
Scoring
Score is assigned if any testcase passes
Allowed Languages
Bash, C, C +114, C ++17, Clojure, C#, D, Erlang, F#, Go, Groov & Haskell, Java 8, Java 14,
Java 17, JavaScript(Node.js), Julia, Kotlin, Lisp (SBCL), Lua, O FCtive-C, OCaml, Octave,
Pascal, Perl, PHP, Python, Python 3, Python 3.8, Racket, Ruby Bust, Scala, Swift,
TypeScript, Visual Basic Output formet
Print the number of ways to divide the array into continuous blocks such that
each block is One block.
Constraints
1N100
0Arr11
Sample input
Sample output
3
e 10
Explanation
Given
-N=3
- Arr=[0,1,0]
Approach
There is exactily one resource that has the value of 1 Hence. the number of ways is 1
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions

Question

LO5 Explain how to generate effective recruitment advertisements.

Answered: 1 week ago