Problem Statement
Suppose that we are using a deck in which there are n cards, numbered 1, 2, ..., n, and that we are given the collection of all the cards that have been removed from the deck. Then we should be able to tell exactly what cards are left in the deck.
Create a class CardCounting that contains a method leftInDeck that is given an int n, the number of cards in the deck, and a int[] seen that contains all the cards that have been removed from the deck. The method returns a int[] that contains exactly the cards that are left in the deck, listed in ascending order.
Definition
- Class:
- CardCounting
- Method:
- leftInDeck
- Parameters:
- int, int[]
- Returns:
- int[]
- Method signature:
- int[] leftInDeck(int n, int[] seen)
- (be sure your method is public)
Constraints
- n will be between 1 and 50 inclusive
- seen will contain between 1 and n elements inclusive
- the elements of seen will be distinct values between 1 and n inclusive
Examples
8
{6,2,8}Returns: { 1, 3, 4, 5, 7 }The deck originally contains cards 1, 2, 3, 4, 5, 6, 7, and 8. The cards 6, 2, and 8 have been removed from the deck. The remaining 5 cards in the deck, listed in ascending order, are 1, 3, 4, 5, and 7.11
{10,3,8,1,2,9}Returns: { 4, 5, 6, 7, 11 }Six cards have been seen. There are still five cards in the deck.11
{10,3,8,1,2,9,4,5,6,11,7}Returns: { }All the cards have been seen. The deck contains no cards at all, so the returned int[] should contain exactly 0 elements.