Statistics

Problem Statement for "Auxanometer"

Problem Statement

An auxanometer is a device inside a medical cabinet used for measuring height. It is divided vertically into equal 1 centimeter segments. The segments are labeled differently on each side of the device. The left side is used to measure the height of an adult standing on the floor, and the right side is used to measure the height of a child standing on a footstool directly beneath the device. The segments on the left side are labeled nmin to nmax, inclusive, from bottom to top. The segments on the right side are labeled 1 to nmax-nmin+1, inclusive, from bottom to top.

Your task is to determine the number of segments where the concatenation of the number on the left and the number on the right forms a non-decreasing sequence of digits. For example, if the number on the left is 168 and the number on the right is 89, the concatenation is 16889, a non-decreasing sequence of digits. Return the number of such segments on the given auxanometer.

Definition

Class:
Auxanometer
Method:
countIncreasingMarks
Parameters:
int, int
Returns:
int
Method signature:
int countIncreasingMarks(int nmin, int nmax)
(be sure your method is public)

Constraints

  • nmin and nmax will be between 1 and 10^9, inclusive.
  • nmin will be strictly less than nmax.

Examples

  1. 1

    9

    Returns: 9

    Here, the numbers on the left and right are the same. They both go from 1 to 9, so their concatenations are 11, 22, ..., 99, all of which are non-decreasing sequences of digits.

  2. 2

    10

    Returns: 0

    Here, the numbers on the left side go from 2 to 10, and the corresponding numbers on the right side go from 1 to 9. None of the concatenations (21, 32, ..., 98, 109) are non-decreasing sequences of digits.

  3. 1090

    1112

    Returns: 2

    There are only two satisfactory segments here: 1111-22 and 1112-23.

  4. 80

    169

    Returns: 13

  5. 111

    222

    Returns: 9

  6. 2

    100000

    Returns: 0

  7. 11111

    67890

    Returns: 9

  8. 1

    1000000

    Returns: 54

  9. 10

    2345678

    Returns: 8

  10. 1000000

    100000000

    Returns: 8

  11. 1

    1000000000

    Returns: 81

  12. 1001

    327943200

    Returns: 9

  13. 11111

    124523232

    Returns: 9

  14. 111111111

    222222222

    Returns: 9

  15. 999999999

    1000000000

    Returns: 0

  16. 100000000

    1000000000

    Returns: 8

  17. 400000

    999999999

    Returns: 7

  18. 4327

    563067346

    Returns: 5

  19. 10001

    1000001

    Returns: 9

  20. 67352345

    99934352

    Returns: 0

  21. 100000000

    999999999

    Returns: 8

  22. 80993

    239217726

    Returns: 0

  23. 890

    1000000000

    Returns: 22

  24. 15778

    1000000000

    Returns: 16

  25. 568

    1000000000

    Returns: 31

  26. 166566668

    1000000000

    Returns: 82

  27. 15666668

    1000000000

    Returns: 122

  28. 57777779

    1000000000

    Returns: 125

  29. 66644446

    1000000000

    Returns: 165

  30. 66666657

    1000000000

    Returns: 285

  31. 66666668

    1000000000

    Returns: 405

  32. 55555557

    1000000000

    Returns: 495

  33. 3

    5

    Returns: 0

  34. 17

    99999999

    Returns: 5

  35. 80

    1000000000

    Returns: 14

  36. 5

    1000000000

    Returns: 3

  37. 78

    99999999

    Returns: 15

  38. 1

    999999999

    Returns: 81


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: