Unique
TCO14 Round 1C · 2014-03-26 · by misof
Problem Statement
You are given a
Some of the letters may occur multiple times in S. For example, there are three 'a's and two 'n's in "banana".
You dislike duplicates.
For each letter, you want to keep only its first occurrence and delete all the others.
Return the
Constraints
- S will contain between 1 and 1000 characters, inclusive.
- Each character of S will be a lowercase English letter ('a'-'z').
Statement by TopCoder, Inc. — view the original on the archive.
"banana" Returns: "ban"
"aardvark" Returns: "ardvk"
"xxxxx" Returns: "x"
"topcoder" Returns: "topcder"
"a" Returns: "a"
Submissions are judged against all 64 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Unique with a public method string removeDuplicates(string S) · 64 test cases · 2 s / 256 MB per case