上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 36 下一页
摘要: 这道题目我之前做过就不多解释了: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)
摘要: ##我的题解 /* // Definition for a Node. class Node { int val; Node next; Node random; public Node(int val) { this.val = val; this.next = null; this.random 阅读全文
posted @ 2020-07-14 20:03 浅滩浅 阅读(102) 评论(0) 推荐(0)
摘要: class Solution { List<List<Integer>> res = new LinkedList<>(); List<Integer> list = new LinkedList<>(); void backtrack(int[] nums, LinkedList<Integer> 阅读全文
posted @ 2020-07-14 18:06 浅滩浅 阅读(197) 评论(0) 推荐(0)
摘要: class Solution { public int removeDuplicates(int[] nums) { int cnt=0; int len=nums.length; for(int i=1;i<len;i++){ if(nums[i]==nums[i-1]){ for(int j=i 阅读全文
posted @ 2020-07-14 11:04 浅滩浅 阅读(113) 评论(0) 推荐(0)
摘要: class Solution { public int minimumTotal(List<List<Integer>> triangle) { int height = triangle.size(),width=0; int [][]dp = new int[height][]; for(int 阅读全文
posted @ 2020-07-14 10:28 浅滩浅 阅读(179) 评论(0) 推荐(0)
摘要: 解题:这个好像是某年考研题,大概思路就是先遍历链表用一个计数器++,当计数值=k时,再用一个指针遍历链表,两个遍历相差k位,当第一个链表遍历完了,第二个链表遍历到倒数第k个元素。 举例:一个人先跑距离为k,另一个人开始起跑,当第一个人到终点时第二个人距离终点距离为k 代码 /** * Definit 阅读全文
posted @ 2020-07-13 21:45 浅滩浅 阅读(110) 评论(0) 推荐(0)
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 36 下一页
点击右上角即可分享
微信分享提示