Find Recurring Names
Amazon rewards its new users with a discount coupon that can be applied to their first purchase. Some users create more than one account in order to receive the offer multiple times. It was found that their new usernames are only a permutation of their real names.
For examples, if the real usernames of the users are realNames = ["abc", "def"] and the list of all usernames is allNames = ["bca", "abc", "cba", "def"], then the user "abc" must have made multiple accounts as there are three permutations of "abc" in the list of all usernames.
Given an array of realNames an array allNames of usernames for each account, identify the names of users who created accounts more than once. The goal is to return the array of real names of these users in lexicographical order. If there are no such names, return an array containing only the string "None".
Please note that:
realNames, each value is unique, and indicates an individual person.allNames is a permutation of some name in realNames.realNames without a permutation in allNames.
Complete the function findRecurringNames in the editor.
findRecurringNames has the following parameters:
string realNames[n]: the real user namesstring allNames[m]: all registered user names
Returns
string[]: the distinct real names of users with multiple registrations in lexicographical order
1Example 1
2Example 2
Constraints
Limits and guarantees your solution can rely on.
- 1 ≤ n, m ≤ 10^5
- 1 ≤ |realNames[i]|, |allNames[i]| ≤ 10
- Each name in realNames and allNames consists of lowercase English letters only.