TikTok | Phone screen
Anonymous User
1581

Given an input array of 1s and 0s, return a range of array which when flipped will give maximum 0s in the array

Input: [0, 1, 1, 0, 1, 1]
Output: [1, 5]

Explanation: When elements [1, 5] are flipped it gives the array [0, 0, 0, 1, 0, 0] which has max 0s possible, any other range would not be optimal.

Tried to solve calculating subsquences of 1s but failed few cases

Anyone come across a similar problem on leetcode?

Comments (4)