自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(16)
  • 收藏
  • 关注

原创 559. Maximum Depth of N-ary Tree

1.若为二叉树:Time: O(N) Proportional to input nodes, Iterates all nodes once.Space: O(H) Maximum nodes within the temporary call stackBase Case: 当Node为空的时候,返回高度为0Recursive Rule精确版本 :传递: 左右孩子向下索取:下一层的...

2019-05-29 23:08:33 103

原创 965. Univalued Binary Tree

A binary tree is univalued if every node in the tree has the same value.Return true if and only if the given tree is univalued.DFS:class Solution(object): def isUnivalTree(self, root): ...

2019-05-29 22:53:00 66

原创 590. N叉树的后序遍历

给定一个 N 叉树,返回其节点值的后序遍历。1.递归Recursion is easy to implement and understand by definition https://en.wikipedia.org/wiki/Tree_traversal#Post-order_(LRN).def postorder(self, root): """ :t...

2019-05-26 23:09:26 75

原创 589. N叉树的前序遍历

给定一个 N 叉树,返回其节点值的前序遍历。Iterative:class Solution(object): def preorder(self, root): """ :type root: Node :rtype: List[int] """ if not root: ret...

2019-05-26 23:03:23 83

原创 617. 合并二叉树

给定两个二叉树,想象当你将它们中的一个覆盖到另一个上时,两个二叉树的一些节点便会重叠。你需要将他们合并为一个新的二叉树。合并的规则是如果两个节点重叠,那么将他们的值相加作为节点合并后的新值,否则不为 NULL 的节点将直接作为新二叉树的节点。def mergeTrees(self, t1, t2): """ :type t1: TreeNode ...

2019-05-23 23:57:28 56

原创 938. Range Sum of BST

Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive).The binary search tree is guaranteed to have unique values.Example 1:Input:...

2019-05-23 23:50:36 69

原创 496. Next Greater Element I

给定两个没有重复元素的数组 nums1 和 nums2 ,其中nums1 是 nums2 的子集。找到 nums1 中每个元素在 nums2 中的下一个比其大的值。nums1 中数字 x 的下一个更大元素是指 x 在 nums2 中对应位置的右边的第一个比 x 大的元素。如果不存在,对应位置输出-1。示例 1:输入: nums1 = [4,1,2], nums2 = [1,3,4,2].输...

2019-05-23 00:01:28 61

原创 946. Validate Stack Sequences

Input: pushed = [1,2,3,4,5], popped = [4,5,3,2,1]Output: trueExplanation: We might do the following sequence:push(1), push(2), push(3), push(4), pop() -> 4,push(5), pop() -> 5, pop() -> 3...

2019-05-22 23:40:59 71

原创 1047. Remove All Adjacent Duplicates In String

Given a string S of lowercase letters, a duplicate removal consists of choosing two adjacent and equal letters, and removing them.We repeatedly make duplicate removals on S until we no longer can.Re...

2019-05-22 23:15:42 99

原创 1019. 链表中的下一个更大节点

两次遍历,超时:def nextLargerNodes(self, head): """ :type head: ListNode :rtype: List[int] """ if not head: return head res=[] while head ...

2019-05-20 17:54:13 267

原创 328. Odd Even Linked List

给定一个单链表,把所有的奇数节点和偶数节点分别排在一起。请注意,这里的奇数节点和偶数节点指的是节点编号的奇偶性,而不是节点的值的奇偶性。请尝试使用原地算法完成。你的算法的空间复杂度应为 O(1),时间复杂度应为 O(nodes),nodes 为节点总数。def deleteDuplicates(self, head): """ :type head: ListN...

2019-05-19 23:15:42 74

原创 142. 环形链表 II

给定一个链表,返回链表开始入环的第一个节点。 如果链表无环,则返回 null。1.把见过的节点丢集合里,下次再遇见就是环的开始:def detectCycle(self, head): """ :type head: ListNode :rtype: ListNode """ s={None} wh...

2019-05-19 22:48:28 78

原创 86. Partition List

Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of th...

2019-05-19 22:17:54 62

原创 92. Reverse Linked List II

Reverse a linked list from position m to n. Do it in one-pass.Note: 1 ≤ m ≤ n ≤ length of list.Example:Input: 1->2->3->4->5->NULL, m = 2, n = 4Output: 1->4->3->2->5->...

2019-05-19 00:37:02 68

原创 82. Remove Duplicates from Sorted List II

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.Example 1:Input: 1->2->3->3->4->4->5Output: 1->2-...

2019-05-18 23:39:51 56

原创 linux

linux:1.严格区分大小写2.所有内容都是以文件形式保存的,包括硬件硬件文件是/dev/sd[a-p]光盘文件是/dev/sr0等3.linux不靠扩展名区分文件类型,扩展名是为了方便管理员管理文件4.linux所有的存储设备都必须挂载之后用户才能使用,包括硬盘,U盘和光盘5.windows下的程序不能直接在linux中安装和运行...

2019-05-09 23:36:47 68

空空如也

空空如也

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

TA关注的人

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