← 返回 uber 的题目列表Determine if k is balanced in permutation
类型:online_judge
Given a permutation p of numbers from 1 to n, determine if k (1<=k<=n) is balanced, i.e., it exists in a subarray p[l...r] such that the subarray is a permutation of 1..k. Return the result as a binary string.
Constraints: 0 <= n <= 10^5
Example:
Input: p = [1, 2, 4, 3], n = 4 Output: '1101'
Example
Input
4
1 2 4 3
Output
1101