Last active
April 7, 2020 13:23
-
-
Save kolharsam/aeb588dcdf4632efeba2641048dc1050 to your computer and use it in GitHub Desktop.
Cassidy's Interview Question - 07/04/20
This file contains hidden or 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 resultant_string | |
[str_a] | |
(loop [letters (clojure.string/split (apply str (reverse str_a)) #"") | |
letter_stack []] | |
(if (empty? letters) | |
(clojure.string/join letter_stack) | |
(let [current (peek letters)] | |
(if (= current "#") | |
(recur (pop letters) (if (empty? letter_stack) letter_stack (pop letter_stack))) | |
(recur (pop letters) (conj letter_stack current))))))) | |
(defn compareWithBackspace | |
[str_a str_b] | |
(= (resultant_string str_a) (resultant_string str_b))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment