@@ -0,0 +1,1204 @@
+/**%0A * Given a binary tree, return the inorder traversal of its nodes' values.%0A */%0A%0A/** Iterative version **/%0Apublic List%3CInteger%3E inorderTraversal(TreeNode root) %7B%0A  Stack%3CTreeNode%3E stack = new Stack%3C%3E();%0A  HashSet%3CTreeNode%3E set = new HashSet%3C%3E();%0A  List%3CInteger%3E list = new ArrayList%3C%3E();%0A  stack.push(root);%0A  set.add(root);%0A  if (root == null) return list;%0A%0A  while (!stack.isEmpty()) %7B%0A    TreeNode node = stack.pop();%0A    if (node == null) %7B%0A      continue;%0A    %7D%0A%0A    TreeNode left = node.left;%0A    TreeNode right = node.right;%0A    boolean hasLeft = false;%0A    if (left != null && !set.contains(left)) %7B%0A      // Push the current node back into the stack because if left exists then %0A      // it will not be added in this current iteration%0A      stack.push(node);%0A      hasLeft = true;%0A    %7D%0A%0A    while (left != null) %7B%0A      if (!set.contains(left)) %7B%0A        stack.push(left);%0A        set.add(left);%0A      %7D                    %0A      left = left.left;%0A    %7D%0A%0A    if (hasLeft) %7B%0A      // We have to stop the current iteration to add all the left nodes first. %0A      continue;%0A    %7D%0A%0A    list.add(node.val);%0A%0A    if (node.right != null) %7B%0A      stack.push(node.right);%0A    %7D%0A  %7D%0A%0A  return list;%0A%7D%0A

Add binary in order traversal iteratively