Word Pairs
FULLTIME
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.
Example 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"
Example 2 :
Input:
magics = ["abc","a", "a", "b", "ab", "ac"]
Output:
8