keep moving

# Lexicographical Numbers

Given an integer n, return 1 - n in lexicographical order.

For example, given 13, return: [1,10,11,12,13,2,3,4,5,6,7,8,9].

Please optimize your algorithm to use less time and space. The input size may be as large as 5,000,000.

public List<Integer> lexicalOrder(int n) {
List<Integer> list=new ArrayList<Integer>();
if(n<1)
return list;
//list包含了n个数就结束咯
while(list.size()<n){
int lastNum=list.get(list.size()-1);
if(lastNum*10<=n){
}else{
//如果是10的倍数就除以10的n次方
if((lastNum+1)%10==0){
}else{
if(lastNum+1<=n){
}else{
}
}
}
}
return list;
}

public int divideNTen(int n){
while(n%10==0){
n/=10;
}
return n;
}

#### [leetcode 440]K-th Smallest in Lexicographical Order

2016-11-10 21:46:50

#### 字典序—lexicographical order

2015-11-03 16:05:47

#### Lexicographical order, dictionary order, permutation

2016-05-30 20:53:09

#### 440. K-th Smallest in Lexicographical Order

2016-12-19 13:24:40

#### 【Leetcode】386. Lexicographical Numbers

2016-09-15 16:29:48

#### LeetCode笔记：386. Lexicographical Numbers

2017-04-18 09:16:04

#### C++之lexicographical_compare

2014-04-29 20:39:33

#### LeetCode-386. Lexicographical Numbers-思路详解-C++

2017-01-11 16:28:56

#### leetcode---Lexicographical Numbers

2016-08-27 19:39:32

#### Lexicographical Numbers

2016-09-20 15:00:32