Best Anagram Match
Problem statement
Given a lowercase target string and a list of lowercase candidate words, return the lexicographically smallest candidate that is an exact anagram of the target.
An exact anagram has the same length and the same character frequencies. Return the empty string when no candidate qualifies.
Function
findBestAnagram(target: String, candidates: String[]) → StringExamples
Example 1
target = "listen"candidates = ["silent","enlist","google"]return = "enlist"Both silent and enlist are anagrams; enlist is lexicographically smaller.
Example 2
target = "abc"candidates = ["ab","abd"]return = ""No candidate has the same multiset.
Constraints
1 <= target.length <= 10^5.0 <= candidates.length <= 10^5.- All strings contain lowercase English letters.