Problem Brief
Word Pairs
FULLTIMEOA
See Uber online assessment and hiring insights
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.
1Example 1
Input
magics = ["back","backdoor", "gammon", "backgammon", "comeback", "come", "door"]
Output
3
Explanation
The relevant pairs are:
words[0] = "back" and words[1] = "backdoor"
words[0] = "back" and words[3] = "backgommon"
words[4] = "comeback" and words[5] = "come"
2Example 2
Input
magics = ["abc","a", "a", "b", "ab", "ac"]
Output
8
Explanation
N/A for now