Google | SWE Internship OA | Target sum but no target given

Google coding challenge for internship. I can't remember the exact question but ...

Given an array of integer nums, and NO TARGET SUM GIVEN
find the number of subArray that sums to the same target

for e.g nums = [1,9,8 10, 2]

[1,9] and [8,2] adds to the same sum. return the count
ans: 2
Explanation: Both (1 and 9), (8 and 2) adds to 10. 

Constraints: 
The subarray must be unique, ie, you cannot have one element in both subarrays.
The subarray must contain only 2 elements

Another e.g [3,3,3,9] 
ans = 1. [3,3] sum up to 6.

[3,3] [3,3] would be invalid. There can't be duplicates of 3 in both sub arrays

I am looking for similar questions on leetcode or hackerrank. Thanks

Comments (2)