Created
June 18, 2011 10:47
-
-
Save hyone/1032985 to your computer and use it in GitHub Desktop.
4clojure #53 - Longest continuous increasing subsequence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; hyone's solution to Longest Increasing Sub-Seq | |
;; https://4clojure.com/problem/53 | |
(fn longest-inc-seq [coll] | |
(reduce #(let [len-a (count %1) | |
len-b (count %2)] | |
(if (and (> len-b 1) (> len-b len-a)) %2 %1)) | |
[] | |
(reductions | |
(fn [xs y] | |
(if (> y (last xs)) (conj xs y) [y])) | |
[(first coll)] | |
(rest coll)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
lonest of mine . :