摘要: Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.思路:求二叉树最小深度,典型的递归。直接上代码吧,都看得明白。/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right... 阅读全文
posted @ 2014-04-06 17:43 Awy 阅读(124) 评论(0) 推荐(0) 编辑
摘要: Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integer to string, note the restriction of using extra space.You could also try reversing an integer. Howe 阅读全文
posted @ 2014-04-06 17:07 Awy 阅读(116) 评论(0) 推荐(0) 编辑