自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(30)
  • 收藏
  • 关注

原创 2021-04-30(65. 有效数字)

class Solution { public boolean isNumber(String s) { Map<State, Map<CharType, State>> transfer = new HashMap<State, Map<CharType, State>>(); Map<CharType, State> initialMap = new HashMap<CharType, State&

2021-04-30 16:05:43 106 1

原创 2021-04-29(64. 最小路径和)

class Solution { public int minPathSum(int[][] grid) { int n=grid.length; int m=grid[0].length; int [][] dp=new int[n][m]; int sum=0; for(int i=0;i<n;++i){ sum+=grid[i][0]; dp[i][0]=sum

2021-04-29 08:40:30 69

原创 2021-04-28(63. 不同路径 II)

class Solution { public int uniquePathsWithObstacles(int[][] obstacleGrid) { int n=obstacleGrid.length; int m=obstacleGrid[0].length; int dp[][]=new int[n][m]; for(int i=0;i<n;++i){ if(obstacleGrid[i][0]==

2021-04-28 12:46:44 50

原创 2021-04-27(62. 不同路径)

class Solution { int ans=0; public int uniquePaths(int m, int n) { int x=0,y=0; figui(x,y,m,n); return ans; } void figui(int x,int y,int m, int n){ if(x==m||y==n){ return; } if(x==

2021-04-27 16:19:10 76

原创 2021-04-26(61. 旋转链表)

/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) { this.val = val; } * ListNode(int val, ListNode next) { this.val = val; this.next = next; } * }

2021-04-26 09:46:21 60

原创 2021-04-25(60. 排列序列)

class Solution { public String getPermutation(int n, int k) { int[] factorial = new int[n]; factorial[0] = 1; for (int i = 1; i < n; ++i) { factorial[i] = factorial[i - 1] * i; } --k; Stri

2021-04-25 20:23:23 57

原创 2021-04-24(59. 螺旋矩阵 II)

在这里插入代码片

2021-04-25 20:05:26 61

原创 2021-04-23(57. 插入区间)

class Solution { public int[][] insert(int[][] intervals, int[] newInterval) { int[][] temp=new int[intervals.length+1][2]; for(int i=0;i<intervals.length;++i){ temp[i][0]=intervals[i][0]; temp[i][1]=intervals

2021-04-25 19:55:38 53

原创 2021-04-22(56. 合并区间)

class Solution { public int[][] merge(int[][] intervals) { if(intervals==null||intervals.length<=1){ return intervals; } List<int[]> list=new ArrayList<int[]>(); Arrays.sort(intervals,new Compa

2021-04-22 09:28:14 52

原创 2021-04-21(55. 跳跃游戏)

class Solution { public boolean canJump(int[] nums) { int n=nums.length; boolean[] temp=new boolean[n]; temp[0]=true; for(int i=0;i<n;++i){ if(temp[i]==false){ continue; }

2021-04-21 15:28:09 57

原创 2021-04-20(54. 螺旋矩阵)

class Solution { public List<Integer> spiralOrder(int[][] matrix) { List<Integer> order = new ArrayList<Integer>(); if (matrix == null || matrix.length == 0 || matrix[0].length == 0) { return order;

2021-04-20 20:33:27 59

原创 2021-04-19(52. N皇后 II)

class Solution { int ans=0; public int totalNQueens(int n) { Set<Integer> col=new HashSet<Integer>(); Set<Integer> d1=new HashSet<Integer>(); Set<Integer> d2=new HashSet<Integer>();

2021-04-19 14:22:53 62

原创 2021-04-18(51. N 皇后)

class Solution { public double myPow(double x, int n) { double ans=1; for(int i=n;i!=0;i/=2){ if(i%2!=0){ ans*=x; } x*=x; } return n>=0?ans:1/ans; }}除了快速幂的知识点

2021-04-19 12:28:56 209

原创 2021-04-17(50. Pow(x, n))

在这里插入代码片

2021-04-17 10:21:12 65

原创 2021-04-16(49. 字母异位词分组)

class Solution { public List<List<String>> groupAnagrams(String[] strs) { Map<String,ArrayList<String>> temp=new HashMap<String,ArrayList<String>>(); for (String s:strs){ char[] c=s.toChar

2021-04-16 09:10:11 50

原创 2021-04-15(48. 旋转图像)

class Solution { public void rotate(int[][] matrix) { int n=matrix.length; int[][] temp=new int[n][n]; for(int i=0;i<n;++i){ for(int j=0;j<n;++j){ temp[i][j]=matrix[n-1-j][i]; }

2021-04-15 14:31:08 66

原创 2021-04-14(47. 全排列 II)

class Solution { boolean[] f; public List<List<Integer>> permuteUnique(int[] nums) { List<List<Integer>> ans=new ArrayList<List<Integer>>(); List<Integer> list=new ArrayList<Integer>()

2021-04-14 13:55:26 69

原创 2021-04-13(46. 全排列)

class Solution { public List<List<Integer>> permute(int[] nums) { List<List<Integer>> ans=new ArrayList<>(); List<Integer> list=new ArrayList<>(); backtrack(ans,list,nums); retur

2021-04-13 17:59:56 58

原创 2021-04-12(45. 跳跃游戏 II)

class Solution { public int jump(int[] nums) { int n=nums.length; if(n==1||n==0){ return 0; } int[] dp=new int[n]; dp[n-1]=0; //n-1位置到最后一个位置的跳跃次数为0 for(int i=n-2;i>=0;--i){

2021-04-12 14:17:28 65

原创 2021-04-11(44. 通配符匹配)

class Solution { public boolean isMatch(String s, String p) { int m=s.length(); int n=p.length(); boolean[][] dp=new boolean[m+1][n+1]; dp[0][0]=true; for(int j=1;j<=n;++j){ if(p.charAt(j-1)=='*'){

2021-04-12 13:59:48 85

原创 2021-04-10(43. 字符串相乘)

class Solution { public String multiply(String num1, String num2) { StringBuilder ans=new StringBuilder("0"); for(int i=num1.length()-1;i>=0;--i){ int jin=0; StringBuilder tempans=new StringBuilder();

2021-04-10 14:35:28 63

原创 2021-04-09(42. 接雨水)

class Solution { public int trap(int[] height) { int left=0,right=height.length-1; int leftmax=0,rightmax=0; int ans=0; while(left<right){ leftmax=Math.max(leftmax,height[left]); rightmax=Math.

2021-04-10 13:13:29 59

原创 2021-04-08(40. 组合总和 II)

class Solution { List<List<Integer>> ans=new ArrayList<List<Integer>>(); List<Integer> path=new ArrayList<Integer>(); public List<List<Integer>> combinationSum2(int[] candidates, int target) {

2021-04-08 17:17:54 68

原创 2021-04-07(41.缺失的第一个正数)

测试

2021-04-07 22:55:56 55

原创 2021-04-06(39. 组合总和)

传递的只是地址而已。只有将temp拷贝一份,才不影响原来的temp。 关注点在于容器的拷贝class Solution { List<List<Integer>> ans=new ArrayList<List<Integer>>(); public List<List<Integer>> combinationSum(int[] candidates, int target) { Arrays.sort

2021-04-06 13:13:07 76

原创 2021-04-05(37. 解数独)

递归 + 回溯的方法枚举所有可能的填法,这个思路还是想的不好。看完题解,确实觉得和8皇后问题异曲同工。class Solution { boolean[][] row=new boolean[9][9]; boolean[][] col=new boolean[9][9]; boolean[][] zi=new boolean[9][9]; public void solveSudoku(char[][] board) { for(int i=0;i<

2021-04-05 12:26:52 61

原创 2021-04-04(36. 有效的数独)

class Solution { public boolean isValidSudoku(char[][] board) { for(int i=0;i<9;++i){ Set<Character> temp=new HashSet<Character>(); for(int j=0;j<9;++j){ if(temp.contains(board[i][j])){

2021-04-04 12:57:31 281

原创 2021-04-03(34. 在排序数组中查找元素的第一个和最后一个位置)

class Solution { public int[] searchRange(int[] nums, int target) { int[] ans={-1,-1}; int left=0,right=nums.length-1; while(left<=right){ int mid=(left+right)/2; if(nums[mid]==target){

2021-04-03 16:38:35 56

原创 2021-04-02(33. 搜索旋转排序数组)

class Solution { public int search(int[] nums, int target) { int n=nums.length; if(n==0){ return -1; } if(n==1){ return nums[0]==target?0:-1; } int l=0,r=n-1; while(l<=r

2021-04-02 08:24:39 63

原创 2021-04-01(32. 最长有效括号)

class Solution { public int longestValidParentheses(String s) { int ans=0; if(s.length()==0){ return ans; } Stack<Character> stack=new Stack<Character>(); stack.push(s.charAt(0));

2021-04-01 17:03:00 50

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除