Skip to content

Instantly share code, notes, and snippets.

@InterviewBytes InterviewBytes/ Secret
Created Jun 13, 2017

What would you like to do?
Flatten Binary tree 2
package com.interviewbytes.trees;
public class Flatten2 {
private TreeNode prev = null;
public void flatten(TreeNode root) {
if (root == null) return;
root.right = prev;
root.left = null;
prev = root;
package com.interviewbytes.trees;
public class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode(int x) {
val = x;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.