Skip to content

Instantly share code, notes, and snippets.

@kolharsam
Last active April 7, 2020 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kolharsam/aeb588dcdf4632efeba2641048dc1050 to your computer and use it in GitHub Desktop.
Save kolharsam/aeb588dcdf4632efeba2641048dc1050 to your computer and use it in GitHub Desktop.
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