This document summarizes different approaches to solve a LeetCode problem involving finding the maximum length of a contiguous subarray with equal number of 0s and 1s. Approach 1 uses a brute force method while the optimal approach uses a hashmap to store the running sum at each index. The author's initial approach also used a brute force method but their optimal solution involved resolving the matrix to the left or right and concatenating substrings like in the optimal approach.
This document summarizes different approaches to solve a LeetCode problem involving finding the maximum length of a contiguous subarray with equal number of 0s and 1s. Approach 1 uses a brute force method while the optimal approach uses a hashmap to store the running sum at each index. The author's initial approach also used a brute force method but their optimal solution involved resolving the matrix to the left or right and concatenating substrings like in the optimal approach.
This document summarizes different approaches to solve a LeetCode problem involving finding the maximum length of a contiguous subarray with equal number of 0s and 1s. Approach 1 uses a brute force method while the optimal approach uses a hashmap to store the running sum at each index. The author's initial approach also used a brute force method but their optimal solution involved resolving the matrix to the left or right and concatenating substrings like in the optimal approach.
1 525 Medium Contigious array of max equal 0 & 1 Brute Force 2 Perform String Shifts Brute Force Approach 2 make array of n * 2 + 1 length and store sum at every index Resolve matrix to left or right and concat substring Optimal Approach My Approach Use hashmap to store sum at every index Approach 1 Resolve matrix to left or right and concat substring Optimal Approach Link Remarks https://leetcode.com/problems/contiguous-array/ if 0 is found decrement sum otherwise increase Resolve left and right to one displacementvariable https://leetcode.com/explore/featured/card/30-day-leetcoding-challenge/529/week-2/3299/ Revision Runtime Percentile 0 21ms 35.83% 0 0ms