Back to problems

Bit Pattern (MTS)

Algorithm · Salesforce · Easy

You are given an integer array nums. For each position i, you need to check two conditions: whether the value nums[i] has already appeared at some index before i, and whether it will appear again at some index after i. Based on these checks, construct two binary strings of the same length as nums. The first string, call it prev, should have '1' at index i if nums[i] exists in the prefix nums[0..i-1]; otherwise put '0'. The second string, next, should have '1' at index i if…

Checking your access…