Design a unique string generator for URL shortening with a character frequency threshold.
Unlock detailed company stats for this questionUpgrade
Design a class that generates unique strings for URL shortening. Strings use only lowercase a-z; a threshold T is given and the frequency of any character in a generated string must be <= T; each call returns a unique string; shorter strings must be returned before longer ones (order within the same length does not matter). API: class URLShortener { URLShortener(int threshold); string getNext(); } Example with T = 2: a, b, c, ..., z, then aa, ab, ac, ..., zz (every character appears at most 2 times). Base-26 enumeration with carry works, skipping invalid strings (e.g. with T = 2, 110 and 112 are valid but 111 is not).
Format · Google L4 onsite.
Community answers
No answers contributed by the community yet.
Related questions
Given a string, return all characters with frequency greater than 1.Related courses

Course

Course
Course
