Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankush1oo8 committed Mar 16, 2024
1 parent 786449d commit c959c05
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Hashing/largestSubarraySum0.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ public static void main(String[] args) {

for (int j = 0; j < arr.length; j++) {
sum += arr[j];
if (sum == 0) {
len = j + 1;
} else {

if (map.containsKey(sum)) {
len = Math.max(len, j - map.get(sum));
} else {
map.put(sum, j);
map.put(sum, j);
}
}

}
System.out.println("Largest subarray with sum equal to 0: " + len);
}
Expand Down

0 comments on commit c959c05

Please sign in to comment.