Largest Sub Array with Sum Zero
In this class, We discuss Largest Sub Array with Sum Zero.
Readers can prepare an entire competitive coding course to crack product development companies. Click Here.
The reader should have basic coding skills to work with competitive coding. Click here.
Question:
Given an array of integers.
Find the length of largest sub array with sum zero.
Example:
Input: [10, 5, -5, 1, 5, -6, 11]
Output: 5
Time complexity: O(N)
Space complexity: O(N)
Logic:
Add the elements in the array.
Maintain the sum and array position in a hash table.
By using the hash table we can easily identify the maximum sub array with zero sum.
The step-by-step explanation is provided in the video.
Code: