class Solution{
public:
//Complete this function
//Function to check whether there is a subarray present with 0-sum or not.
bool subArrayExists(int arr[], int n)
{
int pref_sum=0;
unordered_set<int> s;
for(int i=0;i<n;i++)
{
pref_sum+=arr[i];
if(pref_sum==0) return true;
if(s.find(pref_sum)!=s.end()) return true;
s.insert(pref_sum);
}
return false;
//Your code here
}
};