Connection Status:
Competition Arena > SimpleDuplicateRemover
SRM 274 · 2005-11-23 · by Andrew_Lazarev · Brute Force
Class Name: SimpleDuplicateRemover
Return Type: int[]
Method Name: process
Arg Types: (vector<int>)
Problem Statement

Problem Statement

We have a sequence of integers. We want to remove duplicate elements from it.

You will be given a int[] sequence. For each element that occurs more than once leave only its rightmost occurrence. All unique elements must be copied without changes.

Constraints

  • sequence will have between 1 and 50 elements, inclusive.
  • Each element of sequence will be between 1 and 1000, inclusive.
Examples
0)
{1,5,5,1,6,1}
Returns: {5, 6, 1 }

We left the third 1, the second 2 and the only 6.

1)
{2,4,2,4,4}
Returns: {2, 4 }
2)
{6,6,6,6,6,6}
Returns: {6 }
3)
{1,2,3,4,2,2,3}
Returns: {1, 4, 2, 3 }
4)
{100,100,100,99,99,99,100,100,100}
Returns: {99, 100 }

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

Coding Area

Language: C++17 · define a public class SimpleDuplicateRemover with a public method vector<int> process(vector<int> sequence) · 72 test cases · 2 s / 256 MB per case

Submitting as anonymous