05 2016 档案
摘要:题目描述 实现一个函数,检查二叉树是否平衡,平衡的定义如下,对于树中的任意一个结点,其两颗子树的高度差不超过1。 给定指向树根结点的指针TreeNode* root,请返回一个bool,代表这棵树是否平衡。 解法:1.递归求取节点的高度,注意递归终止条件,其余就是取左右子树最大的高度。 2.递归求取
阅读全文
摘要:Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1->2->3->4, you should return the list as 2->1->4->3. Your a
阅读全文
摘要:Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Given s = "hello", return "holle". Example 2:Given s
阅读全文
摘要: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 fo
阅读全文

浙公网安备 33010602011771号