Maximize the Confusion of an Exam LeetCode solution in JavaScript

1
var maxConsecutiveAnswers = function (answerKey, k) {
2
let [left, right, numOfTrue, numOfFalse, max] = new Array(5).fill(0);
3
const moreChanges = () => numOfTrue > k && numOfFalse > k;
4
while (right < answerKey.length) {
5
if (answerKey[right] === "T") numOfTrue++;
6
if (answerKey[right] === "F") numOfFalse++;
7
while (moreChanges()) {
8
if (answerKey[left] === "T") numOfTrue--;
9
if (answerKey[left] === "F") numOfFalse--;
10
left++;
11
}
12
max = Math.max(max, right - left + 1);
13
right++;
14
}
15
return max;
16
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0