I need help with the following:
flatten ([]) -> [];
flatten([H|T]) -> H ++ flatten(T).
The input list contains other lists with different lengths.
For instance:
flatten([[1,2,3],[4,7],[9,9,9,9,9,9]]).
What is the time complexity of this function? And why?
I got it in O (n), where n is the number of items in the input list.
For instance:
flatten([[1,2,3],[4,7],[9,9,9,9,9,9]]) n=3
flatten([[1,2,3],[4,7],[9,9,9,9,9,9],[3,2,4],[1,4,6]]) n=5
Thanks for the help.