摘要:
这道题目我之前做过就不多解释了:https://www.cnblogs.com/cstdio1/p/13072712.html /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNo 阅读全文
posted @ 2020-07-15 19:22
浅滩浅
阅读(106)
评论(0)
推荐(0)
摘要:
class Solution { public int[] singleNumbers(int[] nums) { Set<Integer> set = new HashSet<>(); int n = nums.length; for(int i=0;i<n;i++){ if(set.contai 阅读全文
posted @ 2020-07-15 19:12
浅滩浅
阅读(118)
评论(0)
推荐(0)
摘要:
思路:排序+分情况 class Solution { public int singleNumber(int[] nums) { Arrays.sort(nums); int len=nums.length; for(int i=1;i<len-1;i++){ if(nums[i]!=nums[i- 阅读全文
posted @ 2020-07-15 18:51
浅滩浅
阅读(113)
评论(0)
推荐(0)
摘要:
解法:分情况:1、缺开头。 2、缺的元素在中间部位。 3、缺的元素在最后一个位置。 class Solution { public int missingNumber(int[] nums) { int len=nums.length; for(int i=1;i<len;i++){ if(nums 阅读全文
posted @ 2020-07-15 18:21
浅滩浅
阅读(227)
评论(0)
推荐(0)
摘要:
经典dp问题 class Solution { public int maxValue(int[][] grid) { int m=grid.length,n=grid[0].length; for(int i=0;i<m;i++){ for(int j=0;j<n;j++){ if(i==0&&j 阅读全文
posted @ 2020-07-15 13:44
浅滩浅
阅读(102)
评论(0)
推荐(0)