Here is the description of the the problem
Given an integer N, write a function which returns an integer array of size N, containing the numbers from 1 to N in a random order. Each number from 1 to N must appear once and must not repeat.
- What is the running time of your algorithm?
- Can your algorithm be improved?
For example: if you are given the number 4, your output must generate something like 4213, 2413, 3124, etc.
Invalid outputs would be 1123, 4444, 244.
Any ideas to solve the problem?
Here is a hint: look up what a Fisher-Yates shuffle is.