Problem · Array
Generate Seen Binary Strings
Learn this problemProblem statement
You are given an integer array arr. Return two binary strings of length arr.length:
- The first string has
1at indexiifarr[i]appears anywhere after indexi; otherwise it has0. - The second string has
1at indexiifarr[i]appears anywhere before indexi; otherwise it has0.
Function
generateSeenBinaryStrings(arr: int[]) → String[]Examples
Example 1
arr = [1,2,3,1,2,4,5]return = ["1100000","0001100"]The first two values appear again later, so the first string starts with 11. The values at indices 3 and 4 appeared earlier, so the second string has 1 at those positions.