摘要: class Solution { public void solveSudoku(char[][] board) { boolean[][][] used=new boolean[3][9][9]; for(int i=0;i<9;i++) for(int j=0;j<9;j++) if(board[... 阅读全文
posted @ 2017-09-23 14:34 Weiyu Wang 阅读(93) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public boolean isValidSudoku(char[][] board) { boolean[][][] used=new boolean[3][9][9]; for(int i=0;i<9;i++) for(int j=0;j<9;j++) ... 阅读全文
posted @ 2017-09-23 13:43 Weiyu Wang 阅读(122) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int[] searchRange(int[] nums, int target) { return new int[]{binarySearch(nums,target,true),binarySearch(nums,target,false)}; } private int binarySe... 阅读全文
posted @ 2017-09-23 13:23 Weiyu Wang 阅读(124) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int search(int[] nums, int target) { int l=0; int r=nums.length-1; while(l<r) { int m=l+(r-l)/2; if(nums[m]=... 阅读全文
posted @ 2017-09-23 13:08 Weiyu Wang 阅读(117) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int longestValidParentheses(String s) { int left=-1; Stack stack=new Stack(); int ret=0; for(int i=0;i<s.length();i++) { ... 阅读全文
posted @ 2017-09-23 11:50 Weiyu Wang 阅读(127) 评论(0) 推荐(0) 编辑
摘要: class Solution { public void nextPermutation(int[] nums) { int i=nums.length-1; while(i>0&&nums[i-1]>=nums[i])i--; if(i==0) { Arrays.sort(nums); ... 阅读全文
posted @ 2017-09-23 07:33 Weiyu Wang 阅读(117) 评论(0) 推荐(0) 编辑
摘要: class Solution { public List findSubstring(String s, String[] words) { List ret=new ArrayList(); if(words.length==0||words[0].length()==0||s.length()==0) return ret; ... 阅读全文
posted @ 2017-09-23 07:18 Weiyu Wang 阅读(130) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int divide(int dividend, int divisor) { boolean isNegtive=dividend0||dividend>0&&divisor=ldivisor) { if(ldividend>=l) { ... 阅读全文
posted @ 2017-09-23 06:22 Weiyu Wang 阅读(128) 评论(0) 推荐(0) 编辑
摘要: http://blog.csdn.net/v_july_v/article/details/7041827 阅读全文
posted @ 2017-09-23 06:00 Weiyu Wang 阅读(111) 评论(0) 推荐(0) 编辑
摘要: class Solution { public ListNode reverseKGroup(ListNode head, int k) { if(head==null||k==1) return head; ListNode preNode=new ListNode(0); preNode.next=head; ... 阅读全文
posted @ 2017-09-23 05:07 Weiyu Wang 阅读(104) 评论(0) 推荐(0) 编辑
摘要: Iteration 阅读全文
posted @ 2017-09-23 02:07 Weiyu Wang 阅读(89) 评论(0) 推荐(0) 编辑
摘要: class Solution { public ListNode mergeKLists(ListNode[] lists) { PriorityQueue que=new PriorityQueue((a,b)->a.val-b.val); for(ListNode list:lists) if(list!=null) ... 阅读全文
posted @ 2017-09-23 01:51 Weiyu Wang 阅读(101) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public List generateParenthesis(int n) { List ret=new ArrayList(); generateParenthesis("", 0, 2*n, ret); return ret; } void generateParenth... 阅读全文
posted @ 2017-09-23 01:41 Weiyu Wang 阅读(105) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public ListNode removeNthFromEnd(ListNode head, int n) { ListNode pre=new ListNode(0); pre.next=head; ListNode p=pre,q=pre; for(int i=0;i<n... 阅读全文
posted @ 2017-09-23 01:30 Weiyu Wang 阅读(112) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public List> fourSum(int[] nums, int target) { List> ret=new ArrayList>(); Arrays.sort(nums); for(int i=0;i<nums.length;i++) i... 阅读全文
posted @ 2017-09-23 01:23 Weiyu Wang 阅读(122) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public List letterCombinations(String digits) { LinkedList que=new LinkedList(); if(digits.length()==0) return que; String[] btns=new S... 阅读全文
posted @ 2017-09-23 01:11 Weiyu Wang 阅读(135) 评论(0) 推荐(0) 编辑