Find Balanced Numbers in a Permutation
Given a permutation P of length N, determine for each k (1 ≤ k ≤ N) if k is balanced, where k is balanced if there exists a contiguous subarray that forms a permutation of numbers 1 to k. Return a binary string where the i-th character is '1' if k is balanced, otherwise '0'.
Asked at:
Uber
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early February, 2026
Uber
Mid-level
Given a permutation P of length N, a number k is balanced if there are two indices l, r such that the numbers[P[l], P[l+1] ...P[r]] form a permutation of numbers 1 ,2.....k For each k ( 1<= k<=n) , determine if it is balanced and return a binary strinf where ith character is 1 if balanced else 0 Example: p = [4,1,3,2] output = "1011"
Hello Interview Premium
Your account is free and you can post anonymously if you choose.