Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 1 9 Max. score: 2 0 . 0 0 One block You are working in the resource distribution team of your company. A One
Question
Max. score:
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 You are given an array Arrcontaining N resource values.
What is the number of ways to divide the array into continuous blocks such that each block is One block.
Function description
Complete the function OneBlock which takes aninteger N and an array Arr. This function takes the following 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 dont provide boilerplate code
The first line contains an integer Ndenoting the number of resources.
The second line containsN spaceseparatedintegersdenoting the value of resources.
Output format
Printthe number of ways to divide the array into continuous blocks such that each block is One block.
Constraints
Sample input
Sample output
Explanation
Given
N
Arr
Approach
There is exactly one resource that has the value of Hence, the number of ways is
The following test cases are the actual test cases of this question that may be used to evaluate your submission.
Sample input
Sample output
Sample input
Sample output
Sample input
Sample output
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: secs for each input file
Memory Limit: MB
Source Limit: KB
Scoring
Score is assigned if any testcase passes
Allowed Languages
Bash, C C C Clojure, C# D Erlang, F# Go Groovy, Haskell, Java Java JavaScriptNodejs Julia, Kotlin, Lisp SBCL Lua, ObjectiveC OCaml, Octave, Pascal, Perl, PHP Python, Python Python Racket, Ruby, Rust, Scala, Swift, TypeScript, Visual Basic
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started