TopcoderArchive
SRM23 Nov 2005
SRM 274

SimpleDuplicateRemover

Problem statement, definition, constraints, and public examples.

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.

Definition

Class:
SimpleDuplicateRemover
Method:
process
Parameters:
int[]
Returns:
int[]
Method signature:
int[] process(int[] sequence)
(be sure your method is public)

Constraints

  • sequence will have between 1 and 50 elements, inclusive.
  • Each element of sequence will be between 1 and 1000, inclusive.

Examples

  1. {1,5,5,1,6,1}
    Returns: {5, 6, 1 }
    We left the third 1, the second 2 and the only 6.
  2. {2,4,2,4,4}
    Returns: {2, 4 }
  3. {6,6,6,6,6,6}
    Returns: {6 }
  4. {1,2,3,4,2,2,3}
    Returns: {1, 4, 2, 3 }
  5. {100,100,100,99,99,99,100,100,100}
    Returns: {99, 100 }
Back to all problems