Problem · Array

Generate Seen Binary Strings

Learn this problem
EasySalesforceOA
See Salesforce hiring insights

Problem statement

You are given an integer array arr. Return two binary strings of length arr.length:

  1. The first string has 1 at index i if arr[i] appears anywhere after index i; otherwise it has 0.
  2. The second string has 1 at index i if arr[i] appears anywhere before index i; otherwise it has 0.

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.

More Salesforce problems

drafts saved locally
public String[] generateSeenBinaryStrings(int[] arr) {
  // write your code here
}
arr[1,2,3,1,2,4,5]
expected["1100000", "0001100"]
checking account