摘要:
class Solution { public List> solveNQueens(int n) { int[][] board=new int[n][n]; List> res=new ArrayList>(); nQueens(0,board,res); return res; } private vo... 阅读全文
posted @ 2017-09-25 12:45
Weiyu Wang
阅读(173)
评论(0)
推荐(0)
摘要:
public class Solution { public double myPow(double x, int n) { if(n==0) return 1; if(n < 0) return 1/(x*myPow(x, -(n+1))); double t = myPow(x,n/2)... 阅读全文
posted @ 2017-09-25 09:17
Weiyu Wang
阅读(154)
评论(0)
推荐(0)
摘要:
class Solution { public List> groupAnagrams(String[] strs) { Map> map=new HashMap>(); for(String str: strs) { char[] arr=str.toCharArray(); Arrays.... 阅读全文
posted @ 2017-09-25 08:59
Weiyu Wang
阅读(114)
评论(0)
推荐(0)
摘要:
class Solution { public void rotate(int[][] matrix) { int n=matrix.length; for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) swap(matrix,i,j,j,i); fo... 阅读全文
posted @ 2017-09-25 08:54
Weiyu Wang
阅读(117)
评论(0)
推荐(0)
摘要:
public class Solution { public List> permuteUnique(int[] nums) { List> ret=new ArrayList>(); Arrays.sort(nums); boolean[] used=new boolean[nums.length]; permute(ne... 阅读全文
posted @ 2017-09-25 08:07
Weiyu Wang
阅读(127)
评论(0)
推荐(0)
摘要:
public class Solution { public List> permute(int[] nums) { List> ret=new ArrayList>(); permute(new ArrayList(),ret,nums); return ret; } private void permute(List l... 阅读全文
posted @ 2017-09-25 07:51
Weiyu Wang
阅读(141)
评论(0)
推荐(0)
摘要:
class Solution { public int jump(int[] nums) { int steps=0; int max=0; int cur=0; for(int i=0;i<nums.length-1;i++) { cur=Math.max(cur, i+nums[i... 阅读全文
posted @ 2017-09-25 07:41
Weiyu Wang
阅读(97)
评论(0)
推荐(0)
摘要:
class Solution { public boolean isMatch(String s, String p) { boolean[][] dp=new boolean[p.length()+1][s.length()+1]; dp[0][0]=true; for(int i=1;i0&&(p.charAt(i-1)==s.char... 阅读全文
posted @ 2017-09-25 02:01
Weiyu Wang
阅读(107)
评论(0)
推荐(0)

浙公网安备 33010602011771号