Last active
October 2, 2015 23:52
-
-
Save featheredtoast/33c6a0f8ce041e6c8858 to your computer and use it in GitHub Desktop.
Just because I apparently can't think in an interview room.
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
(defn findSubstring | |
"Finds the longest substring" | |
[s] | |
(->> (range (dec (count s)) 0 -1) | |
(map #(->> s | |
(partition % 1) | |
(map (partial apply str)) | |
(getSubstring))) | |
(drop-while nil?) | |
first)) | |
(defn getSubstring | |
"returns the string if substring match otherwise nil" | |
[candidates] | |
(->> candidates | |
(frequencies) | |
(filter #(< 1 (second %))) | |
(ffirst) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment