Expedia | Round 2 | max length subarray of 1s

Anonymous User
1050
Feb 05, 2024
Feb 05, 2024

Problem Statement:
Given a binary array (consisting of 0s and 1s only) A and a number B, we need to find length of the longest subarrays of ‘1’s possible by changing at most B ‘0’s.

Example:

A = [1, 0, 0, 1, 1, 0, 1] B = 1
Ans: 4

Explaination
we can replace the 0 at index 5 and we get the subarray index 3 to 6 with length 4, so answer is 4

Example 2

A = [1, 0, 0, 1, 0, 1, 0, 1, 0, 1] B = 2
Ans = 5
Explaination
we can replace the 0s at index 6 and 8 and we get the subarray from index 5 to 9 with length 5, so answer is 5

Read Full Interview Experience here
https://leetcode.com/discuss/interview-experience/4681799/Expedia-or-SDE3-or-Gurgaon-or-Feb-2024-Reject

Comments (2)