摘要:
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... 阅读全文
摘要:
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)... 阅读全文
摘要:
class Solution { public List> groupAnagrams(String[] strs) { Map> map=new HashMap>(); for(String str: strs) { char[] arr=str.toCharArray(); Arrays.... 阅读全文
摘要:
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... 阅读全文
摘要:
public class Solution { public List> permuteUnique(int[] nums) { List> ret=new ArrayList>(); Arrays.sort(nums); boolean[] used=new boolean[nums.length]; permute(ne... 阅读全文
摘要:
public class Solution { public List> permute(int[] nums) { List> ret=new ArrayList>(); permute(new ArrayList(),ret,nums); return ret; } private void permute(List l... 阅读全文
摘要:
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... 阅读全文
摘要:
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... 阅读全文