auto commit

This commit is contained in:
CyC2018 2018-03-01 11:03:55 +08:00
parent 58c76022e0
commit 268adf6568

View File

@ -1410,7 +1410,7 @@ public int NumberOf1Between1AndN_Solution(int n) {
```java ```java
int digitAtIndex(int index) { int digitAtIndex(int index) {
if (index >= 0) { if (index < 0) return -1;
int digit = 1; int digit = 1;
while (true) { while (true) {
int amount = getAmountOfDigit(digit); int amount = getAmountOfDigit(digit);
@ -1419,8 +1419,6 @@ int digitAtIndex(int index) {
index -= totalAmount; index -= totalAmount;
digit++; digit++;
} }
}
return -1;
} }
private int getAmountOfDigit(int digit) { private int getAmountOfDigit(int digit) {
@ -1438,6 +1436,11 @@ private int beginNumber(int digits) {
if (digits == 1) return 0; if (digits == 1) return 0;
return (int) Math.pow(10, digits - 1); return (int) Math.pow(10, digits - 1);
} }
public static void main(String[] args) {
Solution solution = new Solution();
System.out.println(solution.digitAtIndex(1001));
}
``` ```
## 45. 把数组排成最小的数 ## 45. 把数组排成最小的数