Longest Subarray of 1s After Deleting One Element Problem
Longest Subarray of 1s After Deleting One Element Problem — ExecCode Easy DSA Practice
Solve the Longest Subarray of 1s After Deleting One Element problem on ExecCode. Free online easy DSA practice in Sliding Window. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given a binary array nums, you should delete one element from it. Your task is to compute the required answer and return the size of the longest non-empty subarray containing only 1 's in the resulting array. Return 0 if there is no such subarray.
Examples
Input {"nums": [1, 1, 0, 1, 1, 1, 0, 1]}; Output 5. Input {"nums": [0, 1, 1, 1, 0]}; Output 3. Input {"nums": [1, 1, 1, 1]}; Output 3
Constraints
1 <= nums.length <= 10^5 nums[i] is either 0 or 1.
Practice Longest Subarray of 1s After Deleting One Element free on ExecCode. Browse DSA problems, topic map, and placement guides.