Perfect Subarray
Practice
3.7 (28 votes)
Arrays
Data structures
Easy
One Dimensional
Prefix sum
Prefix Sum
Problem
72% Success 10657 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given an array $$A$$ of $$N$$ integers. You need to count the subarrays which have the sum of allĀ elements in it a perfect square.

Input
The first line contains an integer $$N$$ that denotes count of elements in the array. Next line contains $$N$$ space separated integers that denote elements of the array.

Output
In the output, you need to print the count of subarrays for which the sum of elements is a perfect square.

Constraints
$$1 \le N \le 5000$$
$$1 \le A[i] \le 10^6$$

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:10
8 votes
Tags:
MathematicsVery-EasyMathematicsMathamatics
Points:20
262 votes
Tags:
Data StructuresEasyHiringOne-dimensionalReady
Points:20
83 votes
Tags:
SortingArraysImplementationData StructuresSet1-D