A web UI has a drop-list selector widget that matches any substring. To enable our users to be more productive, we want...
A web UI has a drop-list selector widget that matches any substring. To enable our users to be more productive, we want to highlight the shortest possible substring in each entry of the list, so they can memorize those unique shortcuts. Write a function that will find the shortest substring that uniquely matches each entry in the list provided. In case of ties use the first substring. Return the same list where each string has its unique substring surrounded by <u> and </u>. Important: while the matching is case insensitive, we want the return values that preserve the original casing. (The string order should also be preserved.) Example: Our widget is used in a UI to label pictures of animals. Annotators must select one of the labels provided for each of the thousands of pictures. We found the unique substrings, underlined here: - "Bird" -> "B<u>i</u>rd" - "Cat" -> "Ca<u>t</u>" - "Cow" -> "<u>Co</u>w" - "Dog" -> "Do<u>g</u>" - "Wallaby" -> "Wa<u>l</u>laby" So the returned list should be: ["B<u>i</u>rd", "Ca<u>t</u>", "<u>Co</u>w", "Do<u>g</u>", "Wa<u>l</u>laby"]