
LeetCode刷题怪
文章平均质量分 84
共享一些刷题经验
贫道绝缘子
如露如电亦如劫,分明眼界无分别。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode刷题攻略
个人笔记原创 2022-08-02 06:45:26 · 249 阅读 · 0 评论 -
Leetcode-138. Copy List with Random Pointer [C++][Java]
A linked list of length n is given such that each node contains an additional random pointer, which could point to any node in the list, or null.原创 2025-03-22 18:16:55 · 682 阅读 · 0 评论 -
Leetcode-1278.Palindrome Partitioning IV [C++][Java]
Given a string s, return true if it is possible to split the string s into three non-empty palindromic substrings. Otherwise, return false.原创 2025-03-16 21:56:21 · 935 阅读 · 0 评论 -
Leetcode-1278.Palindrome Partitioning III [C++][Java]
You are given a string s containing lowercase letters and an integer k. You need to : First, change some characters of s to other lowercase English letters. Then divide s into k non-empty disjoint substrings such that each substring is a palindrome.原创 2025-03-16 21:01:00 · 1126 阅读 · 0 评论 -
Leetcode-132.Palindrome Partitioning II [C++][Java]
Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.原创 2025-03-16 20:05:21 · 1013 阅读 · 0 评论 -
Leetcode-131.Palindrome Partitioning [C++][Java]
Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s.原创 2025-03-16 18:59:45 · 758 阅读 · 0 评论 -
Leetcode-2272. Substring With Largest Variance [C++][Java]
The variance of a string is defined as the largest difference between the number of occurrences of any 2 characters present in the string.原创 2025-03-16 12:11:39 · 695 阅读 · 0 评论 -
Leetcode-853. Car Fleet [C++][Java]
Leetcode-853. Car Fleet原创 2025-03-01 19:26:34 · 792 阅读 · 0 评论 -
Leetcode-1776. Car Fleet II [C++][Java]
Leetcode-1776. Car Fleet II原创 2025-03-01 14:56:27 · 603 阅读 · 0 评论 -
Leetcode-407. Trapping Rain Water II [C++][Java]
Given an m x n integer matrix heightMap representing the height of each unit cell in a 2D elevation map, return the volume of water it can trap after raining.原创 2025-02-23 20:40:43 · 444 阅读 · 0 评论 -
Leetcode-42. Trapping Rain Water [C++][Java]
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.原创 2025-02-23 19:48:10 · 489 阅读 · 0 评论 -
Leetcode-668. Kth Smallest Number in Multiplication Table[C++][Java]
Given three integers m, n, and k, return the kth smallest element in the m x n multiplication table.原创 2025-02-23 18:04:45 · 460 阅读 · 0 评论 -
Leetcode-84. Largest Rectangle in Histogram [C++][Java]
Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram.原创 2025-02-23 17:39:25 · 353 阅读 · 0 评论 -
LeetCode-85. Maximal Rectangle [C++][Java]
Given a binary filled with 's and 's, find the largest rectangle containing only 's and return its area.原创 2025-02-23 17:11:32 · 490 阅读 · 0 评论 -
二叉树中每个节点能到达的最远距离
输入一个只包含0和1的字符串表示二叉树,输出每个节点能到达的最远距离,通过父节点的路径也要考虑。比如输入"111110000010000", 输出[3,2,4,3,3,4]。原创 2025-02-23 16:04:12 · 207 阅读 · 0 评论 -
LeetCode-493. Reverse Pairs
【代码】LeetCode-493. Reverse Pairs。原创 2025-01-12 16:08:57 · 373 阅读 · 0 评论 -
LeetCode-315. Count of Smaller Numbers After Self
Given an integer arraynums, returnan integer arraycountswherecounts[i]is the number of smaller elements to the right ofnums[i].原创 2024-11-30 15:12:41 · 710 阅读 · 0 评论 -
LeetCode-632. Smallest Range Covering Elements from K Lists [C++][Java]
You have k lists of sorted integers in non-decreasing order. Find the smallest range that includes at least one number from each of the k lists.原创 2024-11-24 11:33:59 · 868 阅读 · 1 评论 -
LeetCode-2415. Reverse Odd Levels of Binary Tree [C++][Java]
Given therootof aperfectbinary tree, reverse the node values at eachoddlevel of the tree.原创 2022-12-15 22:49:21 · 701 阅读 · 1 评论 -
LeetCode常见题型——图
图是树的升级版。图通常分为有向(directed)或无向(undirected),有循环(cyclic)或无循环(acyclic),所有节点相连(connected)或不相连(disconnected)。原创 2022-08-22 08:09:55 · 646 阅读 · 0 评论 -
LeetCode-432. All O`one Data Structure [C++][Java]
Design a data structure to store the strings' count with the ability to return the strings with minimum and maximum counts.原创 2022-08-22 08:01:04 · 334 阅读 · 0 评论 -
LeetCode-380. Insert Delete GetRandom O(1) [C++][Java]
You must implement the functions of the class such that each function works inaverageO(1)time complexity.原创 2022-08-21 22:21:03 · 405 阅读 · 0 评论 -
LeetCode-146. LRU Cache [C++][Java]
Design a data structure that follows the constraints of aLeast Recently Used (LRU) cache.原创 2022-08-21 22:11:44 · 1216 阅读 · 0 评论 -
LeetCode-684. Redundant Connection [C++][Java]
You are given a graph that started as a tree withnnodes labeled from1ton, with one additional edge added. The added edge has twodifferentvertices chosen from1ton, and was not an edge that already existed. The graph is represented as an arrayedge原创 2022-08-21 21:59:13 · 294 阅读 · 0 评论 -
LeetCode-882. Reachable Nodes In Subdivided Graph [C++][Java]
In thisnew graph, you want to know how many nodes arereachablefrom the node0, where a node isreachableif the distance ismaxMovesor less.Given the original graph andmaxMoves, returnthe number of nodes that arereachablefrom node0in the new gr原创 2022-08-21 21:32:30 · 343 阅读 · 0 评论 -
LeetCode-1135. Connecting Cities With Minimum Cost [C++][Java]
Return the minimum cost so that for every pair of cities, there exists a pathof connections (possibly of length 1) that connects those two cities together. The cost is the sum of the connection costs used. If the task is impossible, return -1.原创 2022-08-21 11:23:31 · 599 阅读 · 0 评论 -
LeetCode-1059. All Paths from Source Lead to Destination [C++][Java]
Given the edges of a directed graph, and two nodes source and destination of this graph, determine whether or not all paths starting from source eventually end at destination,this problem is pretty straight forward.原创 2022-08-20 08:48:58 · 275 阅读 · 0 评论 -
LeetCode-207. Course Schedule [C++][Java]
There are a total ofnumCoursescourses you have to take, labeled from0tonumCourses - 1. You are given an arrayprerequisiteswhereprerequisites[i] = [ai, bi]indicates that youmusttake coursebifirst if you want to take courseai. reuturn true .......原创 2022-08-19 07:51:47 · 346 阅读 · 0 评论 -
LeetCode-785. Is Graph Bipartite? [C++][Java]
There is anundirectedgraph withnnodes, where each node is numbered between0andn - 1. You are given a 2D arraygraph, wheregraph[u]is an array of nodes that nodeuis adjacent to. More formally, for eachvingraph[u], there is an undirected edge b...原创 2022-08-18 08:12:06 · 314 阅读 · 0 评论 -
LeetCode-210. Course Schedule II [C++][Java]
There are a total ofnumCoursescourses you have to take, labeled from0tonumCourses - 1. You are given an arrayprerequisiteswhereprerequisites[i] = [ai, bi]indicates that youmusttake coursebifirst if you want to take courseai.原创 2022-08-19 07:44:25 · 376 阅读 · 0 评论 -
LeetCode常见题型——树
作为(单)链表的升级版,我们通常接触的树都是二叉树(binary tree),即每个节点最多有两个子节点;且除非题目说明,默认树中不存在循环结构。原创 2022-08-15 08:32:48 · 1217 阅读 · 0 评论 -
LeetCode-450. Delete Node in a BST [C++][Java]
Given a root node reference of a BST and a key, delete the node with the given key in the BST. Returntheroot node reference(possibly updated) of the BST.原创 2022-08-17 08:15:18 · 150 阅读 · 0 评论 -
LeetCode-653. Two Sum IV - Input is a BST [C++][Java]
Given therootof a Binary Search Tree and a target numberk, returntrueif there exist two elements in the BST such that their sum is equal to the given target.原创 2022-08-15 08:02:23 · 184 阅读 · 0 评论 -
LeetCode-897. Increasing Order Search Tree [C++][Java]
Given therootof a binary search tree, rearrange the tree inin-orderso that the leftmost node in the tree is now the root of the tree, and every node has no left child and only one right child.原创 2022-08-17 08:12:29 · 237 阅读 · 0 评论 -
LeetCode-109. Convert Sorted List to Binary Search Tree [C++][Java]
Given theheadof a singly linked list where elements aresorted in ascending order, convert it to a height balanced BST.原创 2022-08-15 06:53:09 · 187 阅读 · 0 评论 -
LeetCode-145. Binary Tree Postorder Traversal [C++][Java]
Given therootof abinary tree, returnthe postorder traversal of its nodes' values.原创 2022-08-15 06:41:53 · 212 阅读 · 0 评论 -
LeetCode-94. Binary Tree Inorder Traversal [C++][Java]
Given therootof a binary tree, returnthe inorder traversal of its nodes' values.原创 2022-08-15 06:29:20 · 150 阅读 · 0 评论 -
LeetCode-106. Construct Binary Tree from Inorder and Postorder Traversal [C++][Java]
Given two integer arraysinorderandpostorderwhereinorderis the inorder traversal of a binary tree andpostorderis the postorder traversal of the same tree, construct and returnthe binary tree.原创 2022-08-15 06:17:44 · 159 阅读 · 0 评论 -
LeetCode-889. Construct Binary Tree from Preorder and Postorder Traversal [C++][Java]
Given two integer arrays,preorderandpostorderwherepreorderis the preorder traversal of a binary tree ofdistinctvalues andpostorderis the postorder traversal of the same tree, reconstruct and returnthe binary tree.原创 2022-08-15 06:08:33 · 154 阅读 · 0 评论 -
LeetCode-530. Minimum Absolute Difference in BST [C++][Java]
Given therootof a Binary Search Tree (BST), returnthe minimum absolute difference between the values of any two different nodes in the tree.原创 2022-08-14 16:27:15 · 199 阅读 · 0 评论