Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5725 |

@blackshadows | 5685 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4908 |

@saiujwal13083 | 4156 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3511 |

@sushant_a | 3453 |

@KshamaGupta | 3318 |

@the_coder95 | 3302 |

Complete Leaderboard | |

Handle | Score |

@avaiesshaik782 | 782 |

@arpitsatnalika | 777 |

@tujhekya | 602 |

@prakharxyz | 601 |

@code_it_ | 591 |

@iamronak | 505 |

@imnm | 500 |

@pradeepkumarjad | 488 |

@satyam0460 | 481 |

@nitesha125 | 468 |

@Rahul Jadhav 1 | 466 |

Complete Leaderboard |

Given an array having both positive and negative integers. The task is to compute the length of the largest subarray with sum 0.

**Example 1:**

**Input:
**N = 8
A[] = {15,-2,2,-8,1,7,10,23}
**Output: **5**
Explanation: **The largest subarray with
sum 0 will be -2 2 -8 1 7.

**Your Task:**

You just have to complete the function **maxLen() **which** **takes two arguments an array** A** and** n,** where n is the size of the array A and returns the length of the largest subarray with 0 sum.

**Expected Time Complexity: **O(N*Log(N)).

**Expected Auxiliary Space: **O(N).

**Constraints:**

1 <= N <= 10^{4}

-1000 <= A[i] <= 1000, for each valid i

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Largest subarray with 0 sum

...

Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.