Lets say I wish to solve the problem - Find maximum product of 3 numbers in an array in Java .
As its easy to solve the problem provided input List is already sorted so if my API method expects a sorted input , would that be a bad design ?
I am assuming the scenario where my API method wouldn't be controlling the source of data & input list population. That I suppose is the usual assumption when you are writing an API.
I would also assume that input could be very very large ( a million items or so ).
Is it too restrictive to impose such restrictions on upstream ?
EDIT : I quoted that problem as an example. I meant to say, does it make more sense to keep a numerical list sorted from the very beginning ( when elements were inserted ) ? Since most problems on a collection of numbers are usually easy when collection is already sorted OR a numerical list being sorted from the very beginning of data flow has some kind of disadvantages too?