Seen Later, Seen Earlier

Company: Salesforce

Difficulty: easy

Problem Statement

Seen Later, Seen Earlier You are given an integer array `arr` of length `n`. Build two binary strings, `later` and `earlier`, each of length `n`: `later[i]` is `1` if the value `arr[i]` occurs at least once at some index strictly greater than `i`, and `0` otherwise. `earlier[i]` is `1` if the value `arr[i]` occurs at least once at some index strictly smaller than `i`, and `0` otherwise. Indices are `0`-based. Both strings contain only the characters `0` and `1`. Input Format The first line contains a single integer `n` - the length of the array. The second line contains `n` space-separated integers `arr[0] arr[1] ... arr[n-1]`. Output Format Print two lines. The first line is the string `later`. The second line is the string `earlier`. Examples ### Example 1 7 1 2 3 1 2 4 5 1100000 0001100 The value `1` at index `0` occurs again at index `3`, and the value `2` at index `1` occurs again at index `4`, so `later` begins with `11`; no other value occurs after its own position. Looking back