Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

3 sequential numbers

Name: eye 2012-04-04 16:06

Alright geniuses, if you think your programming ability is up to par, lets see you solve this:

Write an algorithm which in O(n) time finds 3 indices i, j, and k such that i < j < k and array[i] < array[j] < array[k].

Name: Anonymous 2012-04-04 16:59

f xs = let l = length xs - 1 in head [ (i,j,k) | i <- [0..l], j <- [i..l], k <- [j..l], xs !! i < xs !! j && xs !! j < xs !! k ]

Optimizing to O(n) is left as an exercise to the reader.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List