Problem title
Difficulty
Avg time to solve

Maximum In All Sub-Arrays Of Size K
Easy
10 mins
XOR Property
Easy
15 mins
Is it a Circular Linked List?
Easy
15 mins
Maximum Area Square
Moderate
10 mins
Sum Of Three Stacks
Easy
10 mins
Print All The Nodes At Distance K From The Given Node
Moderate
20 mins
Reversing a Queue
Easy
10 mins
Minimum Travel Cost
Moderate
40 mins
Queen's Palace
Moderate
25 mins
Count smaller people on right side
Easy
10 mins
4

Lexicographical order

Difficulty: MEDIUM
Contributed By
Ashwani |Level 1
Avg. time to solve
35 min
Success Rate
55%

Problem Statement

You are given a positive integer N. Your task is to return a list of integers containing integers from 1 to N (both inclusive) in lexicographically ascending order.

For example:- Given 3 numbers 1, 3 and 10, the lexicographical ascending order will be 1, 10 and 3.

Input format:
The first and only line of input contains a single integer N.
Output format:
The only line of output contains N single space-separated integers i.e integers from 1 to N in lexicographical order.
Note:
You do not need to print anything, it has already been taken care of. Just implement the given function.
Constraints:
1 <= N <=10^6

Time Limit: 1 sec
Sample Input 1:
15
Sample Output 1:
1 10 11 12 13 14 15 2 3 4 5 6 7 8 9 
Sample Input 2:
24
Sample Output 2:
1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 23 24 3 4 5 6 7 8 9 
Reset Code
Full screen
copy-code
Console