摘要: class Solution { public int rob(int[] nums) { if(nums.length==0) return 0; if(nums.length==1) return nums[0]; return Math.max(rob1(nums, 0, nums.le... 阅读全文
posted @ 2017-11-07 08:03 Weiyu Wang 阅读(161) 评论(0) 推荐(0) 编辑
摘要: class Solution { class Trie{ public Trie[] children=new Trie[26]; public boolean isWord=false; public boolean added=false; public void insert(String word) { ... 阅读全文
posted @ 2017-11-07 07:32 Weiyu Wang 阅读(169) 评论(0) 推荐(0) 编辑
摘要: class WordDictionary { private WordDictionary[] children=new WordDictionary[26]; boolean isWord=false; /** Initialize your data structure here. */ public WordDictionary() {... 阅读全文
posted @ 2017-11-07 06:47 Weiyu Wang 阅读(106) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int[] findOrder(int numCourses, int[][] prerequisites) { int[] indegrees=new int[numCourses]; int[][] graph=new int[numCourses][numCourses]; ... 阅读全文
posted @ 2017-11-07 04:28 Weiyu Wang 阅读(140) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int minSubArrayLen(int s, int[] nums) { int i=0; int j=0; int len= Integer.MAX_VALUE; int sum=0; while(j=s) { ... 阅读全文
posted @ 2017-11-07 04:17 Weiyu Wang 阅读(85) 评论(0) 推荐(0) 编辑
摘要: class Trie { Trie[] children=new Trie[26]; boolean isWord=false; /** Initialize your data structure here. */ public Trie() { } /** Inserts a word into... 阅读全文
posted @ 2017-11-07 02:32 Weiyu Wang 阅读(98) 评论(0) 推荐(0) 编辑
摘要: class Solution { public boolean canFinish(int numCourses, int[][] prerequisites) { int[] indegrees=new int[numCourses]; int[][] graph=new int[numCourses][numCourses]; for(... 阅读全文
posted @ 2017-11-07 02:17 Weiyu Wang 阅读(135) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int rangeBitwiseAnd(int m, int n) { int r=Integer.MAX_VALUE; while((m&r)!=(n&r)) r=r<<1; return n&r; } } 阅读全文
posted @ 2017-10-31 13:08 Weiyu Wang 阅读(103) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int numIslands(char[][] grid) { int count=0; for(int i=0;i=grid.length||j=grid[0].length||grid[i][j]!='1') return; grid[i][j]='2'; ... 阅读全文
posted @ 2017-10-26 01:48 Weiyu Wang 阅读(119) 评论(0) 推荐(0) 编辑
摘要: class Solution { public List rightSideView(TreeNode root) { List res=new ArrayList(); rightView(root, res, 0); return res; } private void rightView(TreeNode node, ... 阅读全文
posted @ 2017-10-26 01:31 Weiyu Wang 阅读(119) 评论(0) 推荐(0) 编辑