Split S into 3-character card names, print GRESKA if any card repeats, otherwise print the missing count out of 13 for suits P, K, H and T.
Easy3Hash mapStringInterviewNo attempts yetTime limit1sMemory limit32 MBJinsol took up robotics and decided to build a robot that checks whether a set of poker cards is complete. The robot's job is to recognize the suit and the number of a card. To keep the task simple, assume that every card has exactly one suit and one number.
Each suit is written as a letter instead of the actual symbol. A spade is P, a heart is K, a diamond is H, and a club is T. The number is an integer from 1 to 13.
The robot writes a card as a three-character card name TXY. T is the suit letter and XY is the number written with two digits. If the number has one digit, a leading zero is added, so X is 0. For example, the card with suit P and number 9 is named P09.
A complete set has 52 cards, one for each of the 4 suits combined with each of the 13 numbers.
The robot reads the names of all the cards it currently holds and joins them into one string S. Write a program that reads S and counts how many cards of each suit are missing. If the same card appears twice, print GRESKA instead of the counts.
The first line contains the string S (1≤∣S∣≤1000). S is the concatenation of the names of the cards currently held, and its length is always a multiple of 3.
If the same card appears twice, print GRESKA.
Otherwise print four integers, the number of missing cards for P, K, H, and T in that order. Separate the integers with a single space.