求二叉树的镜像

6-02 2,335 views

思路:
采用递归的思想。对于根节点,若其左子树或右子树不为空,则互换左、右子树,然后对于左、右子树,分别递归上述处理方法,直至叶节点。
示例:
232134562
代码:

Move Zeroes

Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements. For exa...

阅读全文

Odd Even Linked List

Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not ...

阅读全文

Remove Duplicates from Sorted Array

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space...

阅读全文