NewProject Coding is here — build features and fix bugs in real codebases with an AI assistantSee what's new

Given a permutation p of the integers from 1 to n, for each value k from 1 to n, determine whether there exists a contiguous subarray of p with exactly k elements that contains precisely the integers 1, 2, ..., k in any order.

Test Cases
Input
Output
Expected