- 博客(55)
- 收藏
- 关注
![](https://csdnimg.cn/release/blogv2/dist/pc/img/listFixedTop.png)
原创 Leetcode题目集合
基础数据结构概念,基本操作,以及优缺点等 1 字符串操作(标准库,解析,匹配等) 包含 包含 包含 学习材料:https://leetcode-cn.com/explore/learn/card/array-and-string/ 3.无重复字符的最长子串 中等 https://leetcode-cn.com/problems/longest-substring-withou
2021-07-16 16:48:20
256
原创 jd gui 提示The application requires a Java Runtime Environment 1.8.0,设置jdk路径
jd gui 提示The application requires a Java Runtime Environment 1.8.0,设置jdk路径
2022-12-14 17:53:51
3337
1
原创 407. 接雨水 II
题目:https://leetcode-cn.com/problems/trapping-rain-water-ii/import java.util.Comparator;import java.util.PriorityQueue;public class _407_TrapRainWater { public class Location { int row, col, height; public Location(int row, int
2021-08-06 17:51:44
97
原创 215. 数组中的第K个最大元素
题目:https://leetcode-cn.com/problems/kth-largest-element-in-an-array/public class _215_FindKthLargest { public int findKthLargest(int[] nums, int k) { int len = nums.length; return quickSelect(nums, 0, len - 1, k - 1); } pu
2021-08-03 10:10:56
93
原创 98. 验证二叉搜索树
题目:https://leetcode-cn.com/problems/validate-binary-search-tree/import java.util.ArrayList;import java.util.List;public class _98_IsValidBST { private List<Integer> list; public boolean isValidBST(TreeNode root) { list = new
2021-08-02 19:32:04
60
原创 198. 打家劫舍
题目:https://leetcode-cn.com/problems/house-robber/public class _198_Rob { public int rob(int[] nums) { int len = nums.length; int[] dp = new int[len]; for (int i = 0; i < len; i++) { if(i==0) {
2021-08-02 19:31:40
51
原创 230. 二叉搜索树中第K小的元素
题目:https://leetcode-cn.com/problems/kth-smallest-element-in-a-bst/
2021-08-02 19:31:25
49
原创 55. 跳跃游戏
题目:https://leetcode-cn.com/problems/jump-game/public class _55_CanJump { // 贪心算法 public boolean canJump(int[] nums) { int len = nums.length; int rightMost = 0; for (int i = 0; i < len; i++) { if (i <=
2021-07-23 15:55:30
81
1
原创 56. 合并区间
题目:https://leetcode-cn.com/problems/merge-intervals/import java.util.ArrayList;import java.util.Arrays;import java.util.Comparator;public class _56_Merge { public static int[][] merge(int[][] intervals) { Arrays.sort(intervals, new Compar
2021-07-23 15:03:45
63
原创 239. 滑动窗口最大值
题目:https://leetcode-cn.com/problems/sliding-window-maximum/import java.util.*;public class _239_MaxSlidingWindow { // 优先队列-大根堆 public int[] maxSlidingWindow(int[] nums, int k) { int len = nums.length; int[] ans = new int[len
2021-07-23 14:47:51
47
原创 997. 找到小镇的法官
题目:https://leetcode-cn.com/problems/find-the-town-judge/import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;public class _997_FindJudge { public int findJudge(int n, int[][] trust) { if (n ==
2021-07-23 12:52:56
60
原创 102. 二叉树的层序遍历
题目:https://leetcode-cn.com/problems/binary-tree-level-order-traversal/import java.util.ArrayList;import java.util.LinkedList;import java.util.List;import java.util.Queue;public class _102_LevelOrder { public List<List<Integer>> le
2021-07-23 11:31:21
60
原创 144. 二叉树的前序遍历
题目:https://leetcode-cn.com/problems/binary-tree-preorder-traversal/import java.util.ArrayList;import java.util.List;public class _144_PreorderTraversal { List<Integer> ans; public List<Integer> preorderTraversal(TreeNode root) {
2021-07-23 11:31:10
49
原创 652. 寻找重复的子树
题目:https://leetcode-cn.com/problems/find-duplicate-subtrees/import java.util.*;public class _652_FindDuplicateSubtrees { private Map<String, Integer> map; private List<TreeNode> ans; public List<TreeNode> findDuplicateS
2021-07-23 11:30:52
48
原创 36. 有效的数独
题目:https://leetcode-cn.com/problems/valid-sudoku/import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;public class _36_IsValidSudoku { public boolean isValidSudoku(char[][] board) { Map<Int
2021-07-23 11:30:41
48
原创 49. 字母异位词分组
题目:https://leetcode-cn.com/problems/group-anagrams/import java.util.*;public class _49_GroupAnagrams { // 先排序,再用map public List<List<String>> groupAnagrams(String[] strs) { Map<String, List<String>> map = new
2021-07-23 11:30:31
46
原创 18. 四数之和
题目:https://leetcode-cn.com/problems/4sum/import java.util.ArrayList;import java.util.Arrays;import java.util.List;public class _18_FourSum { // 排序+双指针 public List<List<Integer>> fourSum(int[] nums, int target) { List<
2021-07-23 11:30:18
48
原创 387. 字符串中的第一个唯一字符
题目:https://leetcode-cn.com/problems/first-unique-character-in-a-string/import java.util.HashMap;import java.util.LinkedHashMap;import java.util.Map;public class _387_FirstUniqChar { public int firstUniqChar(String s) { Map<Character
2021-07-22 14:50:49
56
原创 706. 设计哈希映射
题目:https://leetcode-cn.com/problems/design-hashmap/import java.util.ArrayList;import java.util.List;public class _706_MyHashMap { private List<Integer> valueList; private List<Integer> keyList; public _706_MyHashMap() {
2021-07-22 14:40:20
53
原创 705. 设计哈希集合
题目:https://leetcode-cn.com/problems/design-hashset/import java.util.ArrayList;import java.util.List;public class _705_MyHashSet { private List<Integer> list; public _705_MyHashSet() { list = new ArrayList<>(); }
2021-07-22 14:29:46
39
原创 23. 合并K个升序链表
题目:https://leetcode-cn.com/problems/merge-k-sorted-lists/public class _23_MergeKLists { public ListNode mergeKLists(ListNode[] lists) { if(lists.length == 0) { return null; } if(lists.length == 2) {
2021-07-22 14:23:18
39
原创 19. 删除链表的倒数第 N 个结点
题目:https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/import java.util.ArrayDeque;import java.util.ArrayList;import java.util.Deque;import java.util.Stack;public class _19_RemoveNthFromEnd { // 计算ListNode长度 public ListNode
2021-07-22 13:00:45
38
原创 160. 相交链表
题目:https://leetcode-cn.com/problems/intersection-of-two-linked-lists/import java.util.HashMap;import java.util.HashSet;public class _160_GetIntersectionNode { // 哈希集合 public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
2021-07-22 11:41:49
30
原创 142. 环形链表 II
题目:https://leetcode-cn.com/problems/linked-list-cycle-ii/import java.util.ArrayList;import java.util.List;public class _142_DetectCycle { public ListNode detectCycle(ListNode head) { if (head == null) { return null;
2021-07-22 11:31:01
28
原创 141. 环形链表
题目:https://leetcode-cn.com/problems/linked-list-cycle/import java.util.ArrayList;import java.util.List;public class _141_HasCycle { // 哈希散列表 public boolean hasCycle(ListNode head) { List<ListNode> list = new ArrayList<>(
2021-07-22 11:22:15
34
原创 707. 设计链表
题目:https://leetcode-cn.com/problems/design-linked-list/import java.util.ArrayList;public class _707_MyLinkedList { private ArrayList<Integer> list; public _707_MyLinkedList() { list = new ArrayList<>(); } public
2021-07-22 11:10:16
83
原创 84. 柱状图中最大的矩形
题目:https://leetcode-cn.com/problems/largest-rectangle-in-histogram/import java.util.Arrays;import java.util.Stack;public class _84_LargestRectangleArea { // 单调栈(双侧) public int largestRectangleArea(int[] heights) { int len = heights.
2021-07-22 11:03:23
45
原创 42. 接雨水
题目:https://leetcode-cn.com/problems/trapping-rain-water/import java.util.Stack;public class _42_TrapWater { // 动态规划 public int trap1(int[] height) { if (height.length == 0) { return 0; } int[] leftMax = ne
2021-07-21 18:18:43
28
原创 150. 逆波兰表达式求值
题目:https://leetcode-cn.com/problems/evaluate-reverse-polish-notation/import java.util.ArrayDeque;import java.util.Deque;public class _150_EvalRPN { public int evalRPN(String[] tokens) { Deque<Integer> deque = new ArrayDeque<>
2021-07-21 15:05:29
52
原创 71. 简化路径
题目:https://leetcode-cn.com/problems/simplify-path/import java.util.ArrayDeque;import java.util.Deque;public class _71_SimplifyPath { public String simplifyPath(String path) { Deque<String> stack = new ArrayDeque<>();
2021-07-21 14:53:34
73
原创 739. 每日温度
题目:https://leetcode-cn.com/problems/daily-temperatures/import java.util.Stack;public class _739_DailyTemperatures { public int[] dailyTemperatures(int[] temperatures) { Stack<Integer> stack = new Stack<>(); int[] resu
2021-07-21 14:14:00
64
原创 20. 有效的括号
题目:https://leetcode-cn.com/problems/valid-parentheses/import java.util.Stack;public class _20_IsValid { public boolean isValid(String s) { Stack brackets = new Stack<Character>(); for (int i = 0; i < s.length(); i++) {
2021-07-21 11:51:13
43
原创 155. 最小栈
题目:https://leetcode-cn.com/problems/min-stack/import java.util.ArrayList;import java.util.Stack;public class _155_MinStack { /** * initialize your data structure here. */ public ArrayList<Integer> list; public Stack<I
2021-07-21 11:49:00
30
原创 933. 最近的请求次数
题目:https://leetcode-cn.com/problems/number-of-recent-calls/import java.util.ArrayDeque;import java.util.ArrayList;import java.util.Deque;import java.util.List;public class _933_RecentCounter { Deque<Integer> deque; List<Integer&g
2021-07-21 11:45:37
32
原创 363. 矩形区域不超过 K 的最大数值和
题目:https://leetcode-cn.com/problems/max-sum-of-rectangle-no-larger-than-k/public class _363_MaxSumSubmatrix { public int maxSumSubmatrix(int[][] matrix, int k) { int rows = matrix.length; int cols = matrix[0].length; int ma
2021-07-21 11:03:33
37
原创 641. 设计循环双端队列
题目:https://leetcode-cn.com/problems/design-circular-deque/import java.util.ArrayDeque;import java.util.Deque;class _641_MyCircularDeque { private Deque<Integer> deque; private int scale; public _641_MyCircularDeque(int k) {
2021-07-21 10:49:47
35
原创 225. 用队列实现栈
题目:https://leetcode-cn.com/problems/implement-stack-using-queues/import java.util.ArrayDeque;import java.util.Deque;public class _225_MyStack { private Deque<Integer> deque; /** Initialize your data structure here. */ public _225
2021-07-20 16:51:40
35
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人