Uber Interview Question for Software Engineers
- 1of 1 vote
You have two arrays of strings, words and parts. Return an array that contains the strings from words, modified so that any occurrences of the substrings from parts are surrounded by square brackets , following these guidelines:- btmakusha February 21, 2018 in United States for Uber Eats
If several parts substrings occur in one string in words, choose the longest one. If there is still more than one such part, then choose the one that appears first in the string.
For words = ["Apple", "Melon", "Orange", "Watermelon"] and parts = ["a", "mel", "lon", "el", "An"], the output should be
findSubstrings(words, parts) = ["Apple", "Me[lon]", "Or[a]nge", "Water[mel]on"].
While "Watermelon" contains three substrings from the parts array, "a", "mel", and "lon", "mel" is the longest substring that appears first in the string.
| Report Duplicate | Flag | PURGE
Uber Software Engineer
Country: United States
Interview Type: In-Person
Open Chat in New Window