Connection Status:
Competition Arena > Unique
TCO14 Round 1C · 2014-03-26 · by misof · Brute Force, String Manipulation
Class Name: Unique
Return Type: String
Method Name: removeDuplicates
Arg Types: (string)
Problem Statement

Problem Statement

You are given a String S of lowercase English letters.

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 String obtained from S by deleting the duplicates of each letter, as described above.

Constraints

  • S will contain between 1 and 1000 characters, inclusive.
  • Each character of S will be a lowercase English letter ('a'-'z').
Examples
0)
"banana"
Returns: "ban"
1)
"aardvark"
Returns: "ardvk"
2)
"xxxxx"
Returns: "x"
3)
"topcoder"
Returns: "topcder"
4)
"a"
Returns: "a"

Submissions are judged against all 64 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

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

Submitting as anonymous