Problem · String

Counterfeit Currency

Learn this problem
EasyBox logoBoxOA

Problem statement

Box is validating attempted cryptocurrency payments. Each coin is represented by a serial number, and only serial numbers that satisfy every rule contribute value.

Serial-number rules

  • The serial number contains between 10 and 12 characters, inclusive.
  • The first 3 characters are distinct uppercase English letters.
  • The next 4 characters form a year from 1900 through 2019, inclusive.
  • The following characters form exactly one allowed denomination: 10, 20, 50, 100, 200, 500, or 1000.
  • The final character is exactly one uppercase English letter.

Tax calculation

For a valid coin with denomination value, apply the 1% processing tax and round the remaining value down. Its contribution is floor(value * 99 / 100).

Complete countCounterfeit. Given the array serialNumber, return the sum of the taxed contributions of all valid serial numbers. Invalid serial numbers contribute 0.

Function

countCounterfeit(serialNumber: String[]) → int

Examples

Example 1

serialNumber = ["AVG190420T","RTF20001000Z","QWER201850G","AFA199620E","ERT1947200T","RTY20202004","DRV1984500V","ETB2010400G"]return = 1702

The valid denominations are 20, 1000, 200, and 500. After applying the tax, their contributions are 19, 990, 198, and 495.

The returned sum is 19 + 990 + 198 + 495 = 1702.

Constraints

  • 0 < n ≤ 10^5
  • 1 ≤ |serialNumber[i]| ≤ 14

More Box problems

drafts saved locally
public int countCounterfeit(String[] serialNumber) {
  // write your code here
}
serialNumber["AVG190420T","RTF20001000Z","QWER201850G","AFA199620E","ERT1947200T","RTY20202004","DRV1984500V","ETB2010400G"]
expected1702
checking account