Problem of the day
You are given an integer ‘n’.
Your task is to return an array containing integers from ‘n’ to ‘1’ (in decreasing order) without using loops.
In the output, you will see the array returned by you.
Example:
Input: ‘n’ = 5
Output: 5 4 3 2 1
Explanation: An array containing integers from ‘n’ to ‘1’ is [5, 4, 3, 2, 1].
The first line contains one integer, ‘n’, denoting the integer.
Output format:
Return the array as described above.
Note:-
You don't need to print anything. Just implement the given function.
5
5 4 3 2 1
Input: ‘n’ = 5
Output: 5 4 3 2 1
Explanation: An array containing integers from ‘5’ to ‘1’ is [5, 4, 3, 2, 1].
2
2 1
Input: ‘n’ = 2
Output: 2 1
Explanation: An array containing integers from ‘2’ to ‘1’ is [2, 1].
The expected time complexity is O(n), where 'n' is the given integer.
The expected space complexity is O(n), where 'n' is the given integer.
1 <= n <= 10^4
Time Limit: 1-sec