Connection Status:
Competition Arena > RoomNumber
SRM 351 · 2007-05-29 · by Andrew_Lazarev · Simple Math, String Manipulation
Class Name: RoomNumber
Return Type: int
Method Name: numberOfSets
Arg Types: (int)
Problem Statement

Problem Statement

You are going to stick the number of your room on the door. The shop near your house suggests wonderful sets of plastic digits. Each set contains exactly ten digits - one of each digit between 0 and 9, inclusive. Return the number of sets required to write your room number. Note that 6 can be used as 9 and vice versa.

Constraints

  • roomNumber will be between 1 and 1,000,000, inclusive.
Examples
0)
122
Returns: 2

Two sets are required because each set contains only one '2' digit.

1)
9999
Returns: 2

Each set contains one '6' digit and one '9' digit. '6' could be used as '9' and therefore two sets are enough.

2)
12635
Returns: 1
3)
888888
Returns: 6
4)
735002
Returns: 2

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

Coding Area

Language: C++17 · define a public class RoomNumber with a public method int numberOfSets(int roomNumber) · 148 test cases · 2 s / 256 MB per case

Submitting as anonymous