摘要: ####题解 java的hashmap的double为key时,有精度问题 转换为求公约数的String key。 class Solution { public int maxPoints(int[][] points) { //牛b我只说一次 HashMap<String, Integer> m 阅读全文
posted @ 2021-01-02 18:09 backTraced 阅读(50) 评论(0) 推荐(0) 编辑
摘要: 题解 哈希表的妙用 绝了 class Solution { public int longestConsecutive(int[] nums) { HashSet<Integer> set = new HashSet<>(); int res = 0; for (int var : nums){ s 阅读全文
posted @ 2021-01-02 18:06 backTraced 阅读(38) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int[] maxSlidingWindow(int[] nums, int k) { int n = nums.length; int index = 0; int[] res = new int[n - k + 1]; Deque<Integer> 阅读全文
posted @ 2021-01-02 18:00 backTraced 阅读(42) 评论(0) 推荐(0) 编辑
摘要: ####题解: 1、难度较大 使用优先队列求解 关键点在于 1 按x轴顺序加入优先队列 如果x轴相同 则 将起点先加入队列 2 遇到起点时加入 遇到终点时将属于终点的起点从优先队列中剔除 3 每次判断peek()出来的高度是否变化 若发生改变则加入结果集中 class Solution { publ 阅读全文
posted @ 2021-01-02 17:55 backTraced 阅读(35) 评论(0) 推荐(0) 编辑
摘要: 给你一个链表数组,每个链表都已经按升序排列。 请你将所有链表合并到一个升序链表中,返回合并后的链表。 示例 1: 输入:lists = [[1,4,5],[1,3,4],[2,6]] 输出:[1,1,2,3,4,4,5,6] 解释:链表数组如下: [ 1->4->5, 1->3->4, 2->6 ] 阅读全文
posted @ 2021-01-02 17:38 backTraced 阅读(51) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int[] dailyTemperatures(int[] T) { if (T == null || T.length == 0) return new int[]; Stack minStack = new Stack<>(); int[] res 阅读全文
posted @ 2021-01-02 17:26 backTraced 阅读(45) 评论(0) 推荐(0) 编辑
摘要: import java.util.ArrayDeque; class MinStack { /** initialize your data structure here. */ private final ArrayDeque<Integer> input; private final Array 阅读全文
posted @ 2021-01-02 17:13 backTraced 阅读(48) 评论(0) 推荐(0) 编辑
摘要: class MyQueue { /** Initialize your data structure here. */ private final Deque<Integer> input; private final Deque<Integer> outout; private int size 阅读全文
posted @ 2021-01-02 17:10 backTraced 阅读(38) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int maxChunksToSorted(int[] arr) { int max = 0; int res = 0; for (int i = 0; i < arr.length; i++) { max = Math.max(arr[i], max 阅读全文
posted @ 2021-01-02 17:07 backTraced 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 编写一个高效的算法来搜索 m x n 矩阵 matrix 中的一个目标值 target 。该矩阵具有以下特性: 每行的元素从左到右升序排列。 每列的元素从上到下升序排列。 该题目解法大概分为3种 1、普通暴力搜索 2、利用数组排序特性:利用二分法和区域分割确定值 class Solution { p 阅读全文
posted @ 2021-01-02 16:46 backTraced 阅读(43) 评论(0) 推荐(0) 编辑