Hi, I have question wondering about getting correct alogrithm in interviews
for example , maximum consecutive 1s problem using sliding window https://leetcode.com/problems/max-consecutive-ones-iii/
My question is will I fail interviews because I do not have fully 100% optimized algorithm like shown below? Leetcode says I beat 64% testcases, and looks like time complexity for this solution I have is O(n) due to using sliding window technique with while loop? Will I fail the interviews? In SF Bay area, attempting to get into FAANG from noname company. YoE 6
Below link is more optimized solution of sliding window with if loop. Below code is my code for solving the problme with sliding window while loop
https://leetcode.com/problems/max-consecutive-ones-iii/discuss/893759/Python-Intuitive-structured-Code
def longestOnes(self, A: List[int], K: int) -> int:
zs, left, ml = 0, 0, 0
for i in range(len(A)):
num = A[i]
if num == 0:
zs += 1
while zs > K:
lnum = A[left]
if lnum == 0:
zs -= 1
left += 1
ml = max(ml, i-left+1)
return ml
```