698. Phone Number Prefix
You are provided with an array of strings called numbers, where each string corresponds to a phone number.
Your task is to determine whether any phone number acts as a prefix to another phone number in the array. Return true if there are absolutely no such prefixes; otherwise, return false.
Example 1:
Input: numbers = ["5" , "8" , "9" , "2"]
Output: true
Explanation:
Since no phone number serves as a prefix for any other number in the array, the answer is true.
Example 2:
Input: numbers = ["91" , "917" , "45" , "91782"]
Output: false
Explanation:
The phone number "91" is a prefix for the number "917". Therefore, the answer is false.
Now Your Turn!
Pick the correct output for the given inputInput: numbers = ["1" , "12" , "4" , "3"]
(Give answer with the boolean output determining if no phone number acts as a prefix to any other)
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 2 <= numbers.length <= 50
- 1 <= numbers[i].length <= 50
- All numbers contain only digits '0' to '9'