Problem · Trie
Word Pairs
Learn this problemProblem statement
Please check out the second source image below for more details :)
Once upon a time in a land of letters and words, there was a curious puzzle that needed solving. The puzzle involved an array of words, each holding a special place in a magical list. The task was to find pairs of words that had a special relationship. Specifically, these pairs were defined by either the two words being exactly the same or one word starting with the other.
Function
wordPairs(magics: String[]) → intExamples
Example 1
magics = ["back","backdoor", "gammon", "backgammon", "comeback", "come", "door"]return = 3The relevant pairs are:
words[0] = "back" and words[1] = "backdoor"
words[0] = "back" and words[3] = "backgommon"
words[4] = "comeback" and words[5] = "come"
Example 2
magics = ["abc","a", "a", "b", "ab", "ac"]return = 8N/A for now
More Uber problems
- Last Truck to Leave the LaneOA · Seen Jul 2026
- Chain of CommandOA · Seen Jul 2026
- Jump Game with Prime-3 StepsOA · Seen Jun 2026
- Total Palindrome Substring CostOA · Seen Jun 2026
- Earliest Time All Users Are ConnectedPHONE SCREEN · Seen May 2026
- Tournament Rounds by RankPHONE SCREEN · Seen May 2026
- Farthest Seat AssignmentONSITE INTERVIEW · Seen May 2026
- Convex Function MinimizationPHONE SCREEN · Seen May 2026