I have written a mergeSort
function, which sorted 1 million integers in 750ms, but it takes 9 seconds to take input.
This is how I have taken input to my slice, which is to be sorted.
code snippet:
array := make([]int,n)
for i := 0; i < n; i++ {
fmt.Scanf("%d",&array[i])
}
What I need is, an efficient way to take integers as input into a slice. Input contains only integers, seperated by space or each integer in new-line.
Sample Input 1:
3
9
1
13
Sample Input 2:
3 9 1 13
If efficient solution is available for any one type of Input, it would suffice