技巧
WayneShan
这个作者很懒,什么都没留下…
展开
-
【LeetCode】【JAVA】【072】Jump Game
题目: Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determ原创 2015-03-26 23:55:19 · 146 阅读 · 0 评论 -
【LeetCode】【JAVA】【079】Pow(x, n)
题目: Implement pow(x, n). 思路: 使用二分法:pow(x,n) = pow(x,n/2)*pow(x,n-n/2) Code: public double pow(double x, int n) { if(n<0){ if( n == Integer.MIN_VALUE)原创 2015-04-03 10:56:42 · 195 阅读 · 0 评论 -
【LeetCode】【JAVA】【083】Happy Number
题目: https://leetcode.com/problems/happy-number/ 思路: 用 HashSet 检查重复。另外有地方在讨论 Code: public boolean isHappy(int n) { if(n==1) return true; HashSet hs = new HashSet();原创 2015-04-29 22:06:02 · 172 阅读 · 0 评论