You are given
The weight of the fruits is represented by an array
All those fruits which have the same weight can be sliced in one step.
Task
Your task is to determine the number of steps to slice all the fruits.
Example
Assumption:
Approach:
One of the ways to slice the fruits can be:
In the first step, we can slice fruits at position
In the second step, we can slice fruits at position
In the third step, we can slice fruit at position
In the fourth step, we can slice fruit at position
Hence, the required answer is
Function Description
Complete the function provided in the editor. This function takes two parameters and returns the required answer.
Input Format
Note: This is the input format you must use to provide custom input (available above the Compiler and Test button).
The first line contains denoting the number of test cases. also specifies the number of times you have to run the solve function on a different set of inputs.
For each test case:
The first line contains the size of the array.
The second line contains the array.
Output Format
For each test case, print the answer in a new line.
Constraints
Code Snippets(also called starter code/boilerplate code)
This question has code snippets for C, CPP, Java and Python.
2 6 20 40 30 50 40 20 4 3 6 7 7
4 3
The first line contains the number of test cases.
The first test case is explained in the above example in the question.
In the second test case,
In the first step, we can slice fruits at position
In the second step, we can slice fruit at the
In the third step, we can slice fruit at the
Hence, the required answer is
Please login to use the editor
You need to be logged in to access the code editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor