I was asked the following two questions in a technical interview with Vanta: Suppose you have an array of numbers: [1 2 1 2] and a string: “cat dog cat dog“ And you have to write a function that determines whether the string matches the “pattern“ of the array. To match the pattern, there can’t be two different words corresponding to the same number in that position. For example [1 2 1 2] matches the pattern “cat dog cat dog“ because 1 only maps to cat and 2 only maps to dog, where as
Vanta interview match-pattern
Vanta interview match-pattern
Vanta interview match-pattern
I was asked the following two questions in a technical interview with Vanta: Suppose you have an array of numbers: [1 2 1 2] and a string: “cat dog cat dog“ And you have to write a function that determines whether the string matches the “pattern“ of the array. To match the pattern, there can’t be two different words corresponding to the same number in that position. For example [1 2 1 2] matches the pattern “cat dog cat dog“ because 1 only maps to cat and 2 only maps to dog, where as