2014年7月31日

摘要: 1 public int canCompleteCircuit(int[] gas, int[] cost) { 2 int begin=0; 3 int sum=0; 4 int i=0; 5 int n=0; 6 ... 阅读全文
posted @ 2014-07-31 13:54 thehappyyouth 阅读(238) 评论(0) 推荐(0) 编辑
 
摘要: 1 public int singleNumber(int[] A) {2 int s=0;3 for(int i=0;i<A.length;i++){4 s=s^A[i];5 } 6 return... 阅读全文
posted @ 2014-07-31 13:52 thehappyyouth 阅读(135) 评论(0) 推荐(0) 编辑
 
摘要: 1 package leetcode; 2 3 class RandomListNode { 4 int label; 5 RandomListNode next, random; 6 7 public RandomListNode(int x) { 8 ... 阅读全文
posted @ 2014-07-31 13:50 thehappyyouth 阅读(158) 评论(0) 推荐(0) 编辑
 
摘要: 1 public ListNode detectCycle(ListNode head) { 2 ListNode s=head; 3 ListNode f=head; 4 while(f!=null&&f.next!=null){ 5 ... 阅读全文
posted @ 2014-07-31 13:48 thehappyyouth 阅读(137) 评论(0) 推荐(0) 编辑
 
摘要: 1 public boolean hasCycle(ListNode head) { 2 ListNode s=head; 3 ListNode f=head; 4 while(f!=null&&f.next!=null){ 5 ... 阅读全文
posted @ 2014-07-31 13:47 thehappyyouth 阅读(123) 评论(0) 推荐(0) 编辑
 
摘要: 注意:不一定是一分为2 1 package leetcode; 2 3 import java.util.Set; 4 5 public class WordBreak11 { 6 public boolean wordBreak(String s, Set dict) { 7 ... 阅读全文
posted @ 2014-07-31 13:45 thehappyyouth 阅读(171) 评论(0) 推荐(0) 编辑