自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

贫道绝缘子的博客

科研囹圄二流兵,学术江湖一飘萍。

  • 博客(333)
  • 收藏
  • 关注

原创 《剑指offer》82--二叉树中和为某一值的路径(一)[C++][Java]

《剑指offer》82--二叉树中和为某一值的路径(一)[C++][Java]

2024-01-28 11:07:07 385

原创 《剑指offer》81--调整数组顺序使奇数位于偶数前面(二)[C++][Java]

《剑指offer》81--调整数组顺序使奇数位于偶数前面(二)[C++][Java]

2024-01-28 09:50:13 409

原创 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 422 1

原创 LeetCode常见题型——图

图是树的升级版。图通常分为有向(directed)或无向(undirected),有循环(cyclic)或无循环(acyclic),所有节点相连(connected)或不相连(disconnected)。

2022-08-22 08:09:55 427

原创 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 227

原创 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 293

原创 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 1106

原创 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 210

原创 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 267

原创 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 470

原创 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 194

原创 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 192

原创 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 245

原创 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 204

原创 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 91

原创 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 120

原创 LeetCode常见题型——树

作为(单)链表的升级版,我们通常接触的树都是二叉树(binary tree),即每个节点最多有两个子节点;且除非题目说明,默认树中不存在循环结构。

2022-08-15 08:32:48 1089

原创 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 98

原创 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 128

原创 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 136

原创 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 94

原创 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 94

原创 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 95

原创 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 95

原创 LeetCode-538. Convert BST to Greater Tree [C++][Java]

Given therootof a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum of all keys greater than the original key in BST.

2022-08-14 15:25:01 850

原创 LeetCode-513. Find Bottom Left Tree Value [C++][Java]

Given therootof a binary tree, return the leftmost value in the last row of the tree.

2022-08-14 15:10:34 94

原创 LeetCode-404. Sum of Left Leaves [C++][Java]

Given therootof a binary tree, returnthe sum of all left leaves. Aleafis a node with no children. Aleft leafis a leaf that is the left child of another node.

2022-08-14 14:57:13 750

原创 LeetCode-572. Subtree of Another Tree [C++][Java]

Given the roots of two binary treesrootandsubRoot, returntrueif there is a subtree ofrootwith the same structure and node values ofsubRootandfalseotherwise. A subtree of a binary treetreeis a tree that consists of a node intreeand all of th...

2022-08-14 14:38:10 214

原创 LeetCode-617. Merge Two Binary Trees [C++][Java]

Imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge the two trees into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as t

2022-08-14 12:02:15 250

原创 LeetCode-226. Invert Binary Tree [C++][Java]

Given therootof a binary tree, invert the tree, and returnits root.

2022-08-14 11:26:37 88

原创 LeetCode-208. Implement Trie (Prefix Tree) [C++][Java]

​Atrie(pronounced as "try") orprefix treeis a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker.

2022-08-14 10:56:02 122

原创 LeetCode-669. Trim a Binary Search Tree [C++][Java]

Given therootof a binary search tree and the lowest and highest boundaries aslowandhigh, trim the tree so that all its elements lies in[low, high]. Trimming the tree shouldnotchange the relative structure of the elements

2022-08-14 09:28:46 68

原创 LeetCode-99. Recover Binary Search Tree [C++][Java]

You are given therootof a binary search tree (BST), where the values ofexactlytwo nodes of the tree were swapped by mistake.Recover the tree without changing its structure.

2022-08-14 09:17:05 71

原创 LeetCode-144. Binary Tree Preorder Traversal [C++][Java]

Given therootof a binary tree, returnthe preorder traversal of its nodes' values.

2022-08-13 17:38:07 75

原创 LeetCode-637. Average of Levels in Binary Tree [C++][Java]

Given therootof a binary tree, returnthe average value of the nodes on each level in the form of an array. Answers within10-5of the actual answer will be accepted.

2022-08-13 16:51:44 152

原创 LeetCode-1110. Delete Nodes And Return Forest [C++][Java]

Given therootof a binary tree, each node in the tree has a distinct value.After deleting all nodes with a value into_delete, we are left with a forest (a disjoint union of trees). Return the roots of the trees in the remaining forest.

2022-08-13 16:16:02 175

原创 LeetCode-101. Symmetric Tree [C++][Java]

Given therootof a binary tree,check whether it is a mirror of itself(i.e., symmetric around its center).

2022-08-13 11:52:24 141

原创 LeetCode-113. Path Sum II [C++][Java]

Given therootof a binary tree and an integertargetSum, returnallroot-to-leafpaths where the sum of the node values in the path equalstargetSum. Each path should be returned as a list of the nodevalues, not node references.

2022-08-13 11:40:54 73

原创 LeetCode-112. Path Sum [C++][Java]

Given therootof a binary tree and an integertargetSum, returntrueif the tree has aroot-to-leafpath such that adding up all the values along the path equalstargetSum. Aleafis a node with no children.

2022-08-13 11:15:14 134

原创 LeetCode-437. Path Sum III [C++][Java]

Given therootof a binary tree and an integertargetSum, returnthe number of paths where the sum of the valuesalong the path equalstargetSum. The path does not need to start or end at the root or a leaf, but it must go downwards (i.e., traveling only ...

2022-08-09 08:26:34 188

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除