Milly and special subarrays
Practice
3.9 (544 votes)
Mathematics
Approved
Easy Medium
Problem
39% Success 10474 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Milly is playing with an array A of size N. She is trying to find those non-empty subarrays (sequence of consecutive elements) whose maximum and minimum values are identical. Milly got confused while counting. Your task is to help her in this problem.
Input
- First line of the input will contain T denoting the number of test-cases.
- For every test case, first line will contain N. Next line will contain N space separated integers denoting Ai.
Output
- For every test case, print the required answer in a separate line.
Constraints
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 105
- 1 ≤ |Ai| ≤ 109 Here, || denotes the absolute value.
Explanation
Test case 1:
Special subarrays for the given sample case include :- [1], [1], [3], [1, 1].
Code Editor
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
Tags:
Easy-Medium
Points:30
Tags:
MediumAd-HocLinear AlgebraMatrix ExponentiationAlgorithmsMathematicsOpenApproved
Points:20
7 votes
Tags:
Ad-HocMathematicsOpenApprovedEasy
Editorial
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output