1 Count Run Error

I am getting run error for last testcase.
My approach is that I make a 2D array storing number of zeroes in each subarray then I update my max length subarray from that.

hey @YashJ
Dont use 2D Array
you get OutOfMemoryError
try to solve this problem in O(n) time and O(1) space.
The idea is to use Sliding Window for the given array.

thanks I solved it. And can this question be solved using DP? If yes, then what will be the recursive approach so that I can optimize it to top down/bottom up dp?

And can this question be solved using DP?
answer : Nope
print the length of subarray is easy ( you can do with recursive approach )