自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(62)
  • 资源 (1)
  • 收藏
  • 关注

原创 289.Game of Life [Medium]

https://leetcode.com/problems/game-of-life/According to the Wikipedia’s article: “The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.”Given a board with m by n cells, each

2020-09-30 22:46:52 107

原创 287. Find the Duplicate Number [Medium]

https://leetcode.com/problems/find-the-duplicate-number/Given an array of integersnumscontainingn + 1integers where each integer is in the range[1, n]inclusive.There is onlyone duplicate numberinnums, returnthisduplicate number.Follow-ups:...

2020-09-30 00:15:15 141

原创 926. Flip String to Monotone Increasing [Medium]

A string of'0's and'1's ismonotone increasingif it consists of some number of'0's (possibly 0), followed by some number of'1's (also possibly 0.)We are given a stringSof'0's and'1's, and we may flip any'0'to a'1'or a'1'to a'0'.Return t...

2020-09-28 03:07:23 90

原创 485. Max Consecutive Ones [Easy]

https://leetcode.com/problems/max-consecutive-ones/Given a binary array, find the maximum number of consecutive 1s in this array.Example 1:Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three digits are consecutive 1s.

2020-09-28 01:56:51 120

原创 832. Flipping an Image [Easy]

https://leetcode.com/problems/flipping-an-image/Given a binary matrixA, we want to flip the image horizontally, then invert it, and return the resulting image.To flip an image horizontally means that each row of the image is reversed. For example, fl..

2020-09-28 01:35:54 74

原创 566. Reshape the Matrix [Easy]

https://leetcode.com/problems/reshape-the-matrix/In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data.You're given a matrix represented by a two-dimensiona

2020-09-28 00:38:29 77

原创 1315. Sum of Nodes with Even-Valued Grandparent [Medium]

https://leetcode.com/problems/sum-of-nodes-with-even-valued-grandparent/Given a binary tree, return the sum of values of nodes with even-valued grandparent. (Agrandparentof a node is the parent of its parent, if it exists.)If there are no nodes with...

2020-09-27 23:51:56 87

原创 1305. All Elements in Two Binary Search Trees [Medium]

https://leetcode.com/problems/all-elements-in-two-binary-search-trees/Given two binary search treesroot1androot2.Return a list containingall the integersfromboth treessorted inascendingorder.Example 1:Input: root1 = [2,1,4], root2 = [1,...

2020-09-27 22:55:15 121

原创 766. Toeplitz Matrix [Easy]

https://leetcode.com/problems/toeplitz-matrix/A matrix isToeplitzif every diagonal from top-left to bottom-right has the same element.Now given anM x Nmatrix, returnTrueif and only if the matrix isToeplitz.Example 1:Input:matrix = [ [1,2...

2020-09-27 21:52:07 134

原创 561. Array Partition I [Medium]

https://leetcode.com/problems/array-partition-i/Given an array of2nintegers, your task is to group these integers intonpairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as possibl...

2020-09-27 20:38:35 92

原创 1261. Find Elements in a Contaminated Binary Tree [Medium]

https://leetcode.com/problems/find-elements-in-a-contaminated-binary-tree/Given abinary tree with the following rules:root.val == 0 IftreeNode.val == xandtreeNode.left != null, thentreeNode.left.val == 2 * x + 1 IftreeNode.val == xandtreeNode...

2020-09-27 17:34:38 110

原创 1302. Deepest Leaves Sum [Medium]

https://leetcode.com/problems/deepest-leaves-sum/Given a binary tree, return the sum of values of its deepest leaves.Example 1:Input: root = [1,2,3,4,5,null,6,7,null,null,null,null,8]Output: 15Constraints:The number of nodes in the tree is b

2020-09-27 16:00:47 155

原创 238. Product of Array Except Self [Medium]

https://leetcode.com/problems/product-of-array-except-self/Given an arraynumsofnintegers wheren> 1, return an arrayoutputsuch thatoutput[i]is equal to the product of all the elements ofnumsexceptnums[i].Example:Input: [1,2,3,4]Out...

2020-09-27 15:57:15 87

原创 228. Summary Ranges [Medium]

https://leetcode.com/problems/summary-ranges/Given a sorted integer array without duplicates, return the summary of its ranges.Example 1:Input: [0,1,2,4,5,7]Output: ["0->2","4->5","7"]Explanation: 0,1,2 form a continuous range;4,5 form a c.

2020-09-27 15:18:36 78

原创 216. Combination Sum III [Medium]

https://leetcode.com/problems/combination-sum-iii/Find all valid combinations ofknumbers that sum up tonsuch that the following conditions are true:Only numbers1through9are used. Each number is usedat most once.Returna list of all possible ...

2020-09-27 02:16:22 96

原创 958. Check Completeness of a Binary Tree [Medium]

Given a binary tree, determine if it is acomplete binary tree.Definition of a complete binary tree fromWikipedia:In a complete binary tree every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as ..

2020-09-27 00:48:43 81

原创 919. Complete Binary Tree Inserter

https://leetcode.com/problems/complete-binary-tree-inserter/Acompletebinary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.Write a data structureCBTInserterthat ...

2020-09-26 01:26:04 102

原创 889. Construct Binary Tree from Preorder and Postorder Traversal [Medium]

https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal/Return any binary tree that matches the given preorder and postorder traversals.Values in the traversalspreandpostare distinctpositive integers.Example 1:...

2020-09-26 00:01:03 78

原创 1104. Path In Zigzag Labelled Binary Tree [Medium]

https://leetcode.com/problems/path-in-zigzag-labelled-binary-tree/In an infinite binary tree where every node has two children, the nodes are labelled in row order.In the odd numbered rows (ie., the first, third, fifth,...), the labelling is left to ri

2020-09-25 01:06:59 144

原创 865. Smallest Subtree with all the Deepest Nodes [Medium]

https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/Given therootof a binary tree, the depth of each node isthe shortest distance to the root.Returnthe smallest subtreesuch that it containsall the deepest nodesin the origin...

2020-09-24 23:22:02 83

原创 1448. Count Good Nodes in Binary Tree [Medium]

https://leetcode.com/problems/count-good-nodes-in-binary-tree/Given a binary treeroot, a nodeXin the tree is namedgoodif in the path from root toXthere are no nodes with a valuegreater thanX.Return the number ofgoodnodes in the binary tree....

2020-09-24 00:40:37 155

原创 863. All Nodes Distance K in Binary Tree [Medium]

https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree/We are given a binary tree (with root noderoot), atargetnode, and an integer valueK.Return a list of the values of allnodes that have a distanceKfrom thetargetnode. The answer ...

2020-09-23 23:31:01 95

原创 834. Sum of Distances in Tree [Hard]

https://leetcode.com/problems/sum-of-distances-in-tree/An undirected, connectedtree withNnodes labelled0...N-1andN-1edgesaregiven.Theith edge connects nodesedges[i][0]andedges[i][1]together.Return a listans, whereans[i]is the sum of ...

2020-09-23 00:27:40 126

原创 814. Binary Tree Pruning [Medium]

https://leetcode.com/problems/binary-tree-pruning/We are given the head noderootof a binary tree, where additionally every node's value is either a 0 or a 1.Return the same tree where every subtree (of the given tree) not containing a 1 has been remo..

2020-09-22 01:19:40 132

原创 701. Insert into a Binary Search Tree [Medium]

https://leetcode.com/problems/insert-into-a-binary-search-tree/Given the root node of a binary search tree (BST) and a value to be inserted into the tree,insert the value into the BST. Return the root node of the BST after the insertion. It is guarantee.

2020-09-22 00:55:40 82

原创 589. N-ary Tree Preorder Traversal [Easy]

https://leetcode.com/problems/n-ary-tree-preorder-traversal/Given an n-ary tree, return thepreordertraversal of its nodes' values.Nary-Tree input serializationis represented in their level order traversal, each group of children is separated by the ...

2020-09-22 00:44:49 105

原创 429. N-ary Tree Level Order Traversal [Medium]

https://leetcode.com/problems/n-ary-tree-level-order-traversal/Given an n-ary tree, return thelevel ordertraversal of its nodes' values.Nary-Tree input serializationis represented in their level order traversal, each group of children is separated b...

2020-09-22 00:34:12 77

原创 685. Redundant Connection II [Hard]

https://leetcode.com/problems/redundant-connection-ii/In this problem, a rooted tree is adirectedgraph such that, there is exactly one node (the root) for which all other nodes are descendants of this node, plus every node has exactly one parent, excep..

2020-09-20 21:35:43 138

原创 684. Redundant Connection [Medium]

https://leetcode.com/problems/redundant-connection/In this problem, a tree is anundirectedgraph that is connected and has no cycles.The given input is a graph that started as a tree with N nodes (with distinct values 1, 2, ..., N), with one addition..

2020-09-20 17:11:59 83

原创 671. Second Minimum Node In a Binary Tree [Easy]

https://leetcode.com/problems/second-minimum-node-in-a-binary-tree/Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactlytwoorzerosub-node. If the node has two sub-nodes, then t...

2020-09-20 14:22:44 64

原创 669. Trim a Binary Search Tree [Easy]

https://leetcode.com/problems/trim-a-binary-search-tree/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]. You might need to change the root of the tre...

2020-09-20 01:11:48 100

原创 662. Maximum Width of Binary Tree [Medium]

https://leetcode.com/problems/maximum-width-of-binary-tree/Given a binary tree, write a function to get the maximum width of the given tree. The maximum width of a tree is the maximum width among all levels.The width of one level is defined as the leng

2020-09-20 00:18:44 93

原创 655. Print Binary Tree

https://leetcode.com/problems/print-binary-tree/Print a binary tree in an m*n 2D string array following these rules:The row numbermshould be equal to the height of the given binary tree. The column numbernshould always be an odd number. The root ...

2020-09-19 20:29:18 64

原创 654. Maximum Binary Tree

https://leetcode.com/problems/maximum-binary-tree/Given an integer array with no duplicates. A maximum tree building on this array is defined as follow:The root is the maximum number in the array. The left subtree is the maximum tree constructed from

2020-09-19 18:26:38 109

原创 653. Two Sum IV - Input is a BST

https://leetcode.com/problems/two-sum-iv-input-is-a-bst/Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target.Example 1:Input: 5 / \ 3 6 / \

2020-09-19 17:04:17 101

原创 652. Find Duplicate Subtrees

https://leetcode.com/problems/find-duplicate-subtrees/Given therootof a binary tree, return allduplicate subtrees.For each kind of duplicate subtrees, you only need to return the root node of anyoneof them.Two trees areduplicateif they have th...

2020-09-19 14:24:14 101

原创 637. Average of Levels in Binary Tree

https://leetcode.com/problems/average-of-levels-in-binary-tree/Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array.Example 1:Input: 3 / \ 9 20 / \ 15 7Output: [3, 14.5, 11]

2020-09-19 13:28:14 55

原创 623. Add One Row to Tree

https://leetcode.com/problems/add-one-row-to-tree/Given the root of a binary tree, then valuevand depthd, you need to add a row of nodes with valuevat the given depthd. The root node is at depth 1.The adding rule is: given a positive integer dept...

2020-09-19 03:52:51 89

原创 543. Diameter of Binary Tree

https://leetcode.com/problems/diameter-of-binary-tree/Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of thelongestpath between any two nodes in a tree. This path may or may n..

2020-09-19 02:45:14 67

原创 572. Subtree of Another Tree

https://leetcode.com/problems/subtree-of-another-tree/Given twonon-emptybinary treessandt, check whether treethas exactly the same structure and node values with a subtree ofs. A subtree ofsis a tree consists of a node insand all of this node...

2020-09-17 00:21:50 58

计算机操作系统.xmind

计算机操作系统.xmind

2021-05-20

空空如也

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

TA关注的人

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