自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(53)
  • 资源 (1)
  • 收藏
  • 关注

原创 81.search

81.搜索旋转排序数组Ⅱclass Solution { public boolean search(int[] nums, int target) { int n=nums.length; if(n==0){ return false; } if(n==1){ return nums[0]==target?true:false; } int left=0

2021-01-04 19:39:01 132

原创 12.intToRoman

12.整数转罗马数字class Solution { public String intToRoman(int num) { int[] values={1000,900,500,400,100,90,50,40,10,9,5,4,1}; String[] symbols={"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"}; StringBuilder sb=new StringBu

2021-01-04 17:48:35 105

原创 78.subsets

78.子集class Solution { public List<List<Integer>> subsets(int[] nums) { List<List<Integer>> res=new ArrayList<>(); backtrack(res,nums,new ArrayList<Integer>(),0); return res; } public

2021-01-04 17:18:51 104

原创 47.permuteUnique

47.全排列Ⅱclass Solution { boolean[] vis; public List<List<Integer>> permuteUnique(int[] nums) { List<List<Integer>> res=new ArrayList<>(); List<Integer> output=new ArrayList<>(); vis=

2021-01-04 16:41:15 279 1

原创 46.permute

46.全排列class Solution { public List<List<Integer>> permute(int[] nums) { List<List<Integer>> res=new ArrayList<>(); List<Integer> output=new ArrayList(); for(int num:nums){ output.

2021-01-04 16:09:18 127

原创 216.combinationSum3

216.组合总和Ⅲclass Solution { public List<List<Integer>> combinationSum3(int k, int n) { List<List<Integer>> res=new ArrayList<>(); Deque<Integer> path=new ArrayDeque<>(); if(n<1){

2021-01-04 14:45:56 126 1

原创 40.combinationSum2

40.组合总和Ⅱclass Solution { public List<List<Integer>> combinationSum2(int[] candidates, int target) { Arrays.sort(candidates); List<List<Integer>> res=new ArrayList<List<Integer>>(); Deque<I

2021-01-04 14:30:54 138

原创 39.combinationSum

39.组合总和class Solution { public List<List<Integer>> combinationSum(int[] candidates, int target) { List<List<Integer>> res=new ArrayList<List<Integer>>(); List<Integer> cur=new ArrayList<Inte

2021-01-04 14:05:46 91

原创 22.generateParenthesis

22.括号生成class Solution { public List<String> generateParenthesis(int n) { List<String> ans=new ArrayList<String>(); backtrack(ans,new StringBuilder(),0,0,n); return ans; } public void backtrack(List<

2021-01-04 13:18:40 198

原创 17.letterCombinations

17.电话号码的字母组合class Solution { public List<String> letterCombinations(String digits) { List<String> combiantions=new ArrayList<String>(); if(digits.length()==0){ return combiantions; } Map&lt

2021-01-04 12:23:58 517

原创 70.climbStairs

70.爬楼梯class Solution { public int climbStairs(int n) { if(n<=2){ return n; } int two=1; int one=2; int sum=0; for(int i=3;i<=n;i++){ sum=two+one; two=one;

2021-01-03 21:46:25 82

原创 69.mySqrt

69.x的平方根class Solution { public int mySqrt(int x) { int l=0; int r=x; int ans=0; while(l<=r){ int mid=l+(r-l)/2; if((long)mid*mid<=x){ ans=mid; l=mid+1;

2021-01-03 21:34:53 162

原创 67.addBinary

67.二进制求和class Solution { public String addBinary(String a, String b) { int i=a.length()-1; int j=b.length()-1; int carry=0; StringBuilder builder=new StringBuilder(); while(i>=0&&j>=0){

2021-01-03 20:54:07 59

原创 66.plusOne

66.加一class Solution { public int[] plusOne(int[] digits) { for(int i=digits.length-1;i>=0;i--){ digits[i]++; digits[i]%=10; if(digits[i]!=0){ return digits; } }

2021-01-03 20:26:44 56

原创 64.minPathSum

64.最小路径和class Solution { public int minPathSum(int[][] grid) { if(grid==null||grid.length==0||grid[0].length==0){ return 0; } int m=grid.length; int n=grid[0].length; int[][] dp=new int[m][n];

2021-01-03 20:13:44 148

原创 62.uniquePaths

62.不同路径class Solution { public int uniquePaths(int m, int n) { int[][] f=new int[m][n]; for(int i=0;i<m;i++){ for(int j=0;j<n;j++){ if(i==0||j==0){ f[i][j]=1; }else{

2021-01-02 17:28:17 55

原创 61.rotateRight

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-01-02 17:17:15 80

原创 48.rotate

48.旋转图像class Solution { public void rotate(int[][] matrix) { if(matrix.length==0||matrix.length!=matrix[0].length){ return; } int n=matrix.length; for(int i=0;i<n;i++){ for(int j=0;j<n-i-1;

2021-01-02 16:55:02 62

原创 56.merge

56.合并区间class Solution { public int[][] merge(int[][] intervals) { Arrays.sort(intervals, (v1,v2)->v1[0]-v2[0]); int n=intervals.length; int[][] res=new int[n][2]; int id=-1; for(int i=0;i<n;i++){

2021-01-02 14:09:02 54

原创 55.canJump

55.跳跃游戏class Solution { public boolean canJump(int[] nums) { int most=0; int n=nums.length; for(int i=0;i<n;i++){ if(i<=most){ most=Math.max(most,i+nums[i]); } if(most&g

2021-01-02 12:51:10 152

原创 59.generateMatrix

59.螺旋数组Ⅱclass Solution { public int[][] generateMatrix(int n) { int left=0; int right=n-1; int top=0; int bottom=n-1; int[][] order=new int[n][n]; int num=1; int target=n*n; while(num<

2021-01-02 12:28:19 323

原创 54.spiralOrder

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; }

2020-12-29 17:26:57 62

原创 50.myPow

50.Pow(x,n)class Solution { double quickMul(double x, long N) { double ans = 1.0; // 贡献的初始值为 x double x_contribute = x; // 在对 N 进行二进制拆分的同时计算答案 while (N > 0) { if (N % 2 == 1) { //

2020-12-29 16:38:29 195

原创 53.maxSubArray

53.最大字序和class Solution { public int maxSubArray(int[] nums) { int pre = 0, maxAns = nums[0]; for (int x : nums) { pre = Math.max(pre + x, x); maxAns = Math.max(maxAns, pre); } return maxAns;

2020-12-29 11:36:04 148

原创 58.lengthOfLastWord

58.最后一个单词的长度class Solution { public int lengthOfLastWord(String s) { int end=s.length()-1; while(end>=0&&s.charAt(end)==' '){ end--; } if(end<0){ return 0; } int sta

2020-12-29 11:35:40 54

原创 31.nextPermutation

31.下一个序列class Solution { public void nextPermutation(int[] nums) { int n=nums.length; for(int i=n-1;i>0;i--){ if(nums[i]>nums[i-1]){ Arrays.sort(nums,i,n); for(int j=i;j<n;j++){

2020-12-29 11:34:13 38

原创 33.search

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 left=0; int

2020-12-29 10:53:44 57

原创 24.swapPairs

24两两交换链表中的节点/** * 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 =

2020-12-28 21:31:48 644

原创 34.searchRange

34.在排序数组中查找元素的第一个和最后一个元素class Solution { public int[] searchRange(int[] nums, int target) { int find=reverse(nums,target); if(find==-1){ return new int[]{-1,-1}; } int left=find-1; int rigth=find+1;

2020-12-28 20:22:49 187

原创 36.isValidSudoku

36.有效的数独class Solution { public boolean isValidSudoku(char[][] board) { int[][] rows=new int[9][9]; int[][] col=new int[9][9]; int[][] box=new int[9][9]; for(int i=0;i<9;i++){ for(int j=0;j<9;j++){

2020-12-28 19:36:04 91

原创 25.reverseKGroup

25.K个一组翻转链表/** * 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 = n

2020-12-28 18:33:46 157

原创 38.countAndSay

38.外观数列class Solution { public String countAndSay(int n) { if(n==1){ return "1"; } StringBuffer res=new StringBuffer(); String str=countAndSay(n-1); int length=str.length(); int start=0;

2020-12-28 16:58:19 62

原创 35.searchInsert

35.搜索插入位置class Solution { public int searchInsert(int[] nums, int target) { int length=nums.length; int j=0; for(;j<length;j++){ if(nums[j]==target){ return j; }else if(nums[j]>targ

2020-12-28 16:28:59 102

原创 28.strStr

28.实现strStr()class Solution { public int strStr(String haystack, String needle) { int m=haystack.length(); int n=needle.length(); if(n==0){ return 0; } for(int i=0;i<=m-n;i++){ for(int

2020-12-28 16:12:21 48

原创 27.removeElement

27.移除元素class Solution { public int removeElement(int[] nums, int val) { int length=nums.length; if(length==0){ return 0; } int i=0; for(int j=0;j<length;j++){ if(nums[j]!=val){

2020-12-28 15:30:58 70

原创 26.removeDuplicates

26.删除排序数组中的重复项class Solution { public int removeDuplicates(int[] nums) { int length=nums.length; if(length==0){ return 0; } int i=0; for(int j=1;j<length;j++){ if(nums[i]!=nums[j]){

2020-12-28 15:20:12 238

原创 18.fourSum

18.四数之和在这里插入代码片

2020-12-28 15:09:01 133

原创 19.removeNthFromEnd

19.删除链表的倒数第N个节点class Solution { public ListNode removeNthFromEnd(ListNode head, int n) { return removeNode(head,n)==n?head.next:head; } public int removeNode(ListNode node,int n) { if(node.next == null) return 1; int m = removeNode(n

2020-12-27 21:01:41 360

原创 16.threeSumClosest

16.最接近的三数之和class Solution { public int threeSumClosest(int[] nums, int target) { int n=nums.length; Arrays.sort(nums); int best=10000000; for(int first=0;first<n-2;first++){ if(first>0&&nums[fi

2020-12-27 19:58:27 78

原创 15.threeSum

15.三数之和class Solution { public List<List<Integer>> threeSum(int[] nums) { int n=nums.length; Arrays.sort(nums); List<List<Integer>> ans=new ArrayList<List<Integer>>(); for(int first=0

2020-12-27 18:56:17 49

多标记k近邻 MLKNN详细matlab代码,可直接执行

可以直接执行的matlab程序,内含数据资料,是我在学习过程中总结的,对于新学MLKNN的小伙伴很有帮助,希望可以采纳,有问题可以多多讨论

2019-06-03

空空如也

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

TA关注的人

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