AnagramList
SRM 337 · 2007-02-03 · by soul-net
Problem Statement
An anagram of a string is any string that contains the same characters in any order. For example, the anagrams of "tree" are, in alphabetical order: "eert", "eetr", "eret", "erte", "eter", "etre", "reet", "rete", "rtee", "teer", "tere" and "tree".
You will be given a
Constraints
- s will contain between 1 and 20 characters, inclusive.
- Each character of s will be a lowercase letter ('a'-'z').
- i will be between 0 and 2000000000 (2*109), inclusive.
"tree" 1 Returns: "eetr"
An example from the problem statement.
"tree" 6 Returns: "reet"
Another example from the problem statement.
"tree" 12 Returns: ""
As you can see in the problem statement, the list of anagrams of "tree" only has 12 elements, so none of them has index 12.
"abcabfebda" 5000 Returns: "aadfcabbbe"
"sdoijgfasdkhaiw" 2000000000 Returns: "adsdghwiiokfjas"
Submissions are judged against all 80 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class AnagramList with a public method string getAnagram(string s, int i) · 80 test cases · 2 s / 256 MB per case