摘要: Given an array of integers and an integerk, find out whether there there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and the d... 阅读全文
posted @ 2015-05-31 15:02 ~每天进步一点点~ 阅读(175) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?/**... 阅读全文
posted @ 2015-05-05 14:33 ~每天进步一点点~ 阅读(147) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?/** * Definition for singly-linked list. *... 阅读全文
posted @ 2015-05-05 14:30 ~每天进步一点点~ 阅读(114) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: void rotate(int nums[], int n, int k) { k%=n; reverse(nums,0,n-k-1); reverse(nums,n-k,n-1); rev... 阅读全文
posted @ 2015-04-30 21:49 ~每天进步一点点~ 阅读(90) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: int hammingWeight(uint32_t n) { int result=0; while(n){ n=n&(n-1); result++; ... 阅读全文
posted @ 2015-04-30 21:48 ~每天进步一点点~ 阅读(100) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int rob(int[] nums) { int result=0; int rob=0; int unrob=0; for(int i=0;ib?a:b; }} 阅读全文
posted @ 2015-04-30 21:47 ~每天进步一点点~ 阅读(144) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public boolean isHappy(int n) { int sum=0; if(n==1||n==7) return true; else if(n>1&&n0){ ... 阅读全文
posted @ 2015-04-30 21:46 ~每天进步一点点~ 阅读(102) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */public... 阅读全文
posted @ 2015-04-30 21:45 ~每天进步一点点~ 阅读(97) 评论(0) 推荐(0) 编辑
摘要: Description:Count the number of prime numbers less than a non-negative number,npublic class Solution { public int countPrimes(int n) { if(n(... 阅读全文
posted @ 2015-04-30 21:44 ~每天进步一点点~ 阅读(167) 评论(0) 推荐(0) 编辑
摘要: package my0414;import java.io.UnsupportedEncodingException;public class StringText { /** * @param args * @throws UnsupportedEncodingException */ p... 阅读全文
posted @ 2015-04-14 20:15 ~每天进步一点点~ 阅读(974) 评论(0) 推荐(0) 编辑