auto commit
This commit is contained in:
parent
58c76022e0
commit
268adf6568
|
@ -1410,7 +1410,7 @@ public int NumberOf1Between1AndN_Solution(int n) {
|
|||
|
||||
```java
|
||||
int digitAtIndex(int index) {
|
||||
if (index >= 0) {
|
||||
if (index < 0) return -1;
|
||||
int digit = 1;
|
||||
while (true) {
|
||||
int amount = getAmountOfDigit(digit);
|
||||
|
@ -1419,8 +1419,6 @@ int digitAtIndex(int index) {
|
|||
index -= totalAmount;
|
||||
digit++;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int getAmountOfDigit(int digit) {
|
||||
|
@ -1438,6 +1436,11 @@ private int beginNumber(int digits) {
|
|||
if (digits == 1) return 0;
|
||||
return (int) Math.pow(10, digits - 1);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Solution solution = new Solution();
|
||||
System.out.println(solution.digitAtIndex(1001));
|
||||
}
|
||||
```
|
||||
|
||||
## 45. 把数组排成最小的数
|
||||
|
|
Loading…
Reference in New Issue
Block a user