MCPcopy
hub / github.com/careercup/ctci / count2sInRange

Method count2sInRange

java/Chapter 18/Question18_4/Question.java:22–29  ·  view source on GitHub ↗
(int number)

Source from the content-addressed store, hash-verified

20 }
21
22 public static int count2sInRange(int number) {
23 int count = 0;
24 int len = String.valueOf(number).length();
25 for (int digit = 0; digit < len; digit++) {
26 count += count2sInRangeAtDigit(number, digit);
27 }
28 return count;
29 }
30
31 public static int count2sR(int n) {
32 /* Alternate, messier, solution */

Callers 1

mainMethod · 0.95

Calls 2

count2sInRangeAtDigitMethod · 0.95
lengthMethod · 0.45

Tested by

no test coverage detected