摘要:
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[... 阅读全文
摘要:
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++) ... 阅读全文
摘要:
public class Solution { public int[] searchRange(int[] nums, int target) { return new int[]{binarySearch(nums,target,true),binarySearch(nums,target,false)}; } private int binarySe... 阅读全文
摘要:
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]=... 阅读全文
摘要:
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++) { ... 阅读全文
摘要:
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); ... 阅读全文
摘要:
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; ... 阅读全文
摘要:
public class Solution { public int divide(int dividend, int divisor) { boolean isNegtive=dividend0||dividend>0&&divisor=ldivisor) { if(ldividend>=l) { ... 阅读全文
摘要:
http://blog.csdn.net/v_july_v/article/details/7041827 阅读全文
摘要:
class Solution { public ListNode reverseKGroup(ListNode head, int k) { if(head==null||k==1) return head; ListNode preNode=new ListNode(0); preNode.next=head; ... 阅读全文
摘要:
Iteration 阅读全文
摘要:
class Solution { public ListNode mergeKLists(ListNode[] lists) { PriorityQueue que=new PriorityQueue((a,b)->a.val-b.val); for(ListNode list:lists) if(list!=null) ... 阅读全文
摘要:
public class Solution { public List generateParenthesis(int n) { List ret=new ArrayList(); generateParenthesis("", 0, 2*n, ret); return ret; } void generateParenth... 阅读全文
摘要:
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... 阅读全文
摘要:
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... 阅读全文
摘要:
public class Solution { public List letterCombinations(String digits) { LinkedList que=new LinkedList(); if(digits.length()==0) return que; String[] btns=new S... 阅读全文