Bloomberg Phone Screen Interview
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2023-11-29Added By Anonymous
Source: Link
Bloomberg | unknown | Phone Screen | unknown | unknown
You are given a custome alphabets that could contain alphabets with two characters or three characters in one letter of the alphabets. sort the given strings lexicographicaly based on the custome alphabet.
You are given a custome alphabets that could contain alphabets with two characters or three characters in one letter of the alphabets. sort the given strings lexicographicaly based on the custome alphabet.
custom_alphabet = {"A", "AA", "B", "CC", "D" "DE", "E", "TD", "F", "GAC" "GG", "HA", "II", "J", "KK", "L", "MM", "N", "O", "P", "PL", "QQ", "R", "SS", "T", "UU", "V", "WW", "X", "YY", "Z"}
the list you are given to sort cantains strings formulated by the above alphabets.
Example 1:
given_list = [ "AAB", "AB"]
output = ["AB", "AAB"]
in the strings you have to give priority to letters in the alphabets with more characters like if there is `"AA" `in the string you should not say it is formed by two` A`s instead consider it as one letter as` "AA" `since it exists in the alphabet.
was able to come up with an O(M*N) + O(Nlog(N)) solution where M being the size of the strings and N being the size of the list. And the interviewer seemd to agree on the solution that I proposed and I am waiting for a feedback.