上一页 1 2 3 4 5 6 7 8 9 ··· 22 下一页
摘要: class Solution { public List preorderTraversal(TreeNode root) { Stack stack=new Stack(); List res=new ArrayList(); while(root!=null||!stack.isEmpty()) { ... 阅读全文
posted @ 2017-10-12 06:04 Weiyu Wang 阅读(75) 评论(0) 推荐(0) 编辑
摘要: class Solution { public void reorderList(ListNode head) { ListNode p=head, q=head; while(p!=null&&p.next!=null) { p=p.next.next; q=q.next; ... 阅读全文
posted @ 2017-10-12 05:58 Weiyu Wang 阅读(118) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public ListNode detectCycle(ListNode head) { ListNode p=head,q=head; while(p!=null&&p.next!=null) { p=p.next.next; q=q.next... 阅读全文
posted @ 2017-10-10 12:30 Weiyu Wang 阅读(115) 评论(0) 推荐(0) 编辑
摘要: class Solution { public List wordBreak(String s, List wordDict) { Map> map=new HashMap>(); wordBreak(s, map, wordDict); return map.get(s); } private void wordBreak... 阅读全文
posted @ 2017-10-10 12:20 Weiyu Wang 阅读(134) 评论(0) 推荐(0) 编辑
摘要: class Solution { public boolean wordBreak(String s, List wordDict) { boolean[] dp=new boolean[s.length()+1]; dp[0]=true; for(int i=0;i=0&&w.equals(s.substring(i+1-w.length... 阅读全文
posted @ 2017-10-10 03:50 Weiyu Wang 阅读(118) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public RandomListNode copyRandomList(RandomListNode head) { Map map=new HashMap(); RandomListNode p=new RandomListNode(0); p.next=head; Ran... 阅读全文
posted @ 2017-10-10 02:45 Weiyu Wang 阅读(111) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int singleNumber(int[] nums) { int res=0; for(int i=0;i>i)&1; res|=(sum%3)<<i; } return res; } } 阅读全文
posted @ 2017-10-08 12:20 Weiyu Wang 阅读(90) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int candy(int[] ratings) { int[] candies=new int[ratings.length]; for(int i=0;i=0;i--) if(ratings[i]>ratings[i+1]) candies[i]=M... 阅读全文
posted @ 2017-10-08 12:10 Weiyu Wang 阅读(149) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int canCompleteCircuit(int[] gas, int[] cost) { int total=0,cur=0,start=0; for(int i=0;i=0?start:-1; } } 阅读全文
posted @ 2017-10-07 05:07 Weiyu Wang 阅读(124) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public UndirectedGraphNode cloneGraph(UndirectedGraphNode node) { if(node==null) return null; Map map=new HashMap(); Queue que=new Link... 阅读全文
posted @ 2017-10-07 04:47 Weiyu Wang 阅读(122) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 22 下一页