Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cassidy's Interview Question - 07/04/20
(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