我的代码:
public Node flatten(Node head){ if(head==null) return null; Node tree = head.right; if(head.left!=null){ head.right = head.left; head.left = null; head = flatten(head.right); } if (tree!=null) { head.right = tree head = flatten(head.right); } return head; }
Comments
Post a Comment