advanced
Review: a streak is not a subsequence
This is recall. The code looks finished and is wrong. Find the defect and fix it. You are graded on tests you cannot see.
The weekly report asks for the user's longest sequence of improving check-in scores — scores they can skip in between, order preserved. A helper comes back that walks the array once, counting consecutive improvements, and resets the count on every dip.
/**
* Returns the length of the longest strictly increasing subsequence of
* `scores` — order preserved, entries between the chosen ones skipped.
*/
export function longestIncreasingSubsequence(scores: number[]): number {
if (scores.length === 0) return 0
let best = 1
let currentRun = 1
for (let i = 1; i < scores.length; i++) {
if ((scores[i] as number) > (scores[i - 1] as number)) {
currentRun += 1
best = Math.max(best, currentRun)
} else {
currentRun = 1
}
}
return best
}review — find the defectCtrl+↵ submits · Ctrl+Shift+↵ runsstarter code