Skip to content

Instantly share code, notes, and snippets.

@ygrenzinger
Created March 18, 2017 13:57
Show Gist options
  • Save ygrenzinger/3a79a5001038438c6eea85f29d4b9442 to your computer and use it in GitHub Desktop.
Save ygrenzinger/3a79a5001038438c6eea85f29d4b9442 to your computer and use it in GitHub Desktop.
Clojure best language to win Google Interview :)
;; https://leetcode.com/problems/invert-binary-tree/?tab=Description#/description
;; exemple of a graph [[[1] 2 [3]] 4 [[6] 7 [9]]]
(defn invert [tree]
(if (< (count tree) 2)
tree
[(invert (nth tree 2)) (nth tree 1) (invert (nth tree 0))]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment