Y
Hacker News
new
|
ask
|
show
|
jobs
by
davrosthedalek
4191 days ago
You can always scan through the array, rescale everything by 1/max(input). Then the sleep part is O(1) and the scan part is O(n) -> O(n) total.
1 comments
JoshTriplett
4191 days ago
Division isn't O(1) for arbitrary values (potentially larger than a machine word).
link
pdw
4190 days ago
The same is true for comparison though, isn't it?
link
dalke
4190 days ago
Sleep maxes out at 2147483647 = 2^31 seconds. Generally these problems assume the transdichotomous model, where the machine word size matches the problem size.
link