➤ Problem Link : CRAN02
👉 Hint : edit please
✅ C++ Solution :
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
unordered_map<long long int,long long int>um;
long long int arr[1000001];
while(t--)
{
um.clear();
long long int n,ans=0;
cin>>n;
for(long long int i=0;i<n;i++)
{
cin>>arr[i];
//if(arr[i]==0)
// ans++;
if(i!=0)
arr[i]+=arr[i-1];
if(arr[i]==0)
ans++;
ans+=um[arr[i]];
um[arr[i]]++;
}
cout<<ans<<endl;
}
}
Thank you for your patience reading. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Whatsapp or Facebook.
😇Happy Learning!!
