Professional Documents
Culture Documents
array elements
Difficulty Level : Easy
Last Updated : 16 Sep, 2020
Given an array A[] consisting of N integers from a range [1, N], the task is to
calculate the count of array elements (non-distinct) that can be represented as the
sum of two or more consecutive array elements.
Examples:
Recommended: Please try your approach on {IDE} first, before moving on to the
solution.
Naive Approach: Traverse the given array for each element, find the sum of all
possible subarrays and check if sum of any of the subarrays becomes equal to that
of the current element. Increase count if found to be true. Finally, print the
count obtained.