You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DSA Crack Sheet/README.md
+1
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@
21
21
-[Count pairs with given sum](https://practice.geeksforgeeks.org/problems/count-pairs-with-given-sum5022/1#"view question") - [Cpp Solution](./solutions/Count%20pairs%20with%20given%20sum.cpp)
Given an array of positive and negative numbers. Find if there is a subarray (of size at-least one) with 0 sum.
6
+
7
+
Example 1:
8
+
Input:
9
+
5
10
+
4 2 -3 1 6
11
+
Output:
12
+
Yes
13
+
Explanation:
14
+
2, -3, 1 is the subarray
15
+
with sum 0.
16
+
17
+
Example 2:
18
+
Input:
19
+
5
20
+
4 2 0 1 6
21
+
Output:
22
+
Yes
23
+
Explanation:
24
+
0 is one of the element
25
+
in the array so there exist a
26
+
subarray with sum 0.
27
+
Your Task:
28
+
You only need to complete the function subArrayExists() that takes array and n as parameters and returns true or false depending upon whether there is a subarray present with 0-sum or not. Printing will be taken care by the drivers code.
0 commit comments