Magical Array
Practice
5 (1 votes)
Algorithms
Math
Basic math
Arrays
Problem
94% Success 668 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Problem Statement : 

You are given an array \(A\) of \(N\) integers. You have to find the number of the magical array's that are a subarray of the given array.

A magical array is one which does not have distinct elements.

For example, [2 2 2], [1 1 1] are magical arrays while [2 2 2 3], [3 3 1 3] are not magical arrays.

Input format 

The first line contains one integer \(N\) — the number of elements in the array.

The second line contains \(N\) spaced integers \(A_0,A_1,A_2,.....A_{n-1}\) .

Output format :

              Print one integer, the number of magical subarrays. 

Constraints :

\(1 \leq N \leq 10^5 \\ 1 \leq A_i \leq 10^9\)

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

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
42 votes
Tags:
ReadyBasic ProgrammingOpenEasyMathamatics
Points:20
Tags:
Easy
Points:20
2 votes
Tags:
Easy