Underline Shortest Unique Substrings
Updated
Problem statement
Given an array of nonempty strings, transform every string by underlining its shortest substring that occurs in none of the other strings.
- Compare substrings case-insensitively.
- If several shortest substrings qualify, choose the one whose occurrence starts earliest in the current string.
- Preserve each string's original casing and preserve the input order.
- Wrap only the selected occurrence in the literal tags
<u>and</u>. - If a string has no qualifying substring, return it unchanged.
Return the transformed strings.
Function
underlineShortestUniqueSubstrings(strings: String[]) → String[]Examples
Example 1
strings = ["Bird","Cat","Cow","Dog","Wallaby"]return = ["B<u>i</u>rd","Ca<u>t</u>","<u>Co</u>w","Do<u>g</u>","Wa<u>l</u>laby"]For Bird, b also appears in Wallaby, while i appears in no other string, so the earliest shortest choice is i. For Cow, every single letter appears elsewhere, and Co is the earliest qualifying substring of length two. The other strings have the shown unique single-letter choices.
Example 2
strings = ["Rose","rose"]return = ["Rose","rose"]Comparison ignores case, so every substring of either string occurs in the other. Both strings remain unchanged.
Constraints
1 <= strings.length <= 200.1 <= strings[i].length <= 200.- Every input string contains only uppercase or lowercase ASCII letters.
- The inserted underline tags do not participate in comparisons.
More Atlassian Phone Screen questions
- Merge Overlapping IntervalsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Tennis Court SchedulingPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Implement a Rate LimiterPHONE SCREEN · Seen Oct 2026
- Longest Consistent Activity StreakPHONE SCREEN · Seen Sep 2026
- Music Player Operation SequencePHONE SCREEN · Seen Sep 2026
- Can a Dictionary Word Be Formed from Note Letters?PHONE SCREEN · Seen Feb 2026
- Word Path Moving Only Right or DownPHONE SCREEN · Seen Feb 2026
- Ordered Badge Entry and Exit ViolationsPHONE SCREEN · Seen Aug 2025
- Two Sum with an Ordered Index PairPHONE SCREEN · Seen Aug 2025
- Can You Finish the Teleporter Board?PHONE SCREEN · Seen Jul 2025
Similar questions at other companies
- Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
- Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
- Group AnagramsWorkday · PHONE SCREEN
- Apply Operations to Make a String EmptyFlexport · PHONE SCREENFlexport interview questions
- Word BreakAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Group AnagramsEPAM · PHONE SCREENEPAM interview questions
- Underline Shortest Unique SubstringsMoveworks · PHONE SCREENMoveworks interview questions
- Find Duplicate File GroupsAnthropic · PHONE SCREENAnthropic interview questions
- Invalid TransactionsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Insert an Employee into an Organization HierarchyWaymo · PHONE SCREENWaymo interview questions