Online Notes

Inner Peace

python3 调用heapq库 时遭遇 "TypeError: unorderable types"

Problem同样的代码在LeetCode上提交,在 python3解释器 下报错,换成 python2解释器 下却好好的: 在 StackOverflow 上找到了答案: 仔细对比了python解释器版本,LeetCode上面的python3解释器版本是3.5: 而本地anaconda3带...

2017-12-24 17:20:00

阅读数:395

评论数:0

leetcode: 100. Same Tree

QGiven two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally iden...

2017-11-23 09:02:15

阅读数:288

评论数:0

leetcode: 99. Recover Binary Search Tree

QTwo elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note: A solution using O(n) space...

2017-11-23 09:01:40

阅读数:287

评论数:0

leetcode: 98. Validate Binary Search Tree

QGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only...

2017-11-23 09:00:14

阅读数:256

评论数:0

leetcode: 97. Interleaving String

QGiven s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example, Given: s1 = “aabcc”, s2 = “dbbca”,When s3 = “aadbbcbcac...

2017-11-22 10:25:05

阅读数:277

评论数:0

leetcode: 96. Unique Binary Search Trees

QGiven n, how many structurally unique BST’s (binary search trees) that store values 1…n?For example, Given n = 3, there are a total of 5 unique BST...

2017-11-22 10:24:24

阅读数:208

评论数:0

leetcode: 95. Unique Binary Search Trees II [✗]

QGiven an integer n, generate all structurally unique BST’s (binary search trees) that store values 1…n.For example, Given n = 3, your program shoul...

2017-11-22 10:23:49

阅读数:214

评论数:0

leetcode: 94. Binary Tree Inorder Traversal

QGiven a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree [1,null,2,3], 1 \ 2 / 3 ret...

2017-11-22 10:23:17

阅读数:222

评论数:0

leetcode: 93. Restore IP Addresses

QGiven a string containing only digits, restore it by returning all possible valid IP address combinations.For example: Given “25525511135”,return [...

2017-11-22 10:22:46

阅读数:203

评论数:0

leetcode: 92. Reverse Linked List II

QReverse a linked list from position m to n. Do it in-place and in one-pass.For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4,r...

2017-11-22 10:22:19

阅读数:196

评论数:0

leetcode: 91. Decode Ways

QA message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given an enco...

2017-11-22 10:21:50

阅读数:237

评论数:0

leetcode: 90. Subsets II

QGiven a collection of integers that might contain duplicates, nums, return all possible subsets (the power set).Note: The solution set must not cont...

2017-11-22 10:21:20

阅读数:223

评论数:0

leetcode: 89. Gray Code

QThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total nu...

2017-11-22 10:20:50

阅读数:267

评论数:0

leetcode: 88. Merge Sorted Array

QGiven two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note: You may assume that nums1 has enough space (size ...

2017-11-21 10:12:51

阅读数:242

评论数:0

leetcode: 87. Scramble String

QGiven a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representat...

2017-11-21 10:12:16

阅读数:207

评论数:0

leetcode: 86. Partition List

QGiven 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...

2017-11-21 10:11:51

阅读数:216

评论数:0

leetcode: 85. Maximal Rectangle

Problem# Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. # # For example, given...

2017-11-21 10:11:19

阅读数:223

评论数:0

leetcode: 84. Largest Rectangle in Histogram

Problem# Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, # find the area of largest rectangle...

2017-11-21 10:10:48

阅读数:233

评论数:0

leetcode: 83. Remove Duplicates from Sorted List

QGiven a sorted linked list, delete all duplicates such that each element appear only once.For example, Given 1->1->2, return 1->2. Given ...

2017-11-21 10:10:16

阅读数:214

评论数:0

leetcode: 82. Remove Duplicates from Sorted List II

QGiven a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example, Given 1...

2017-11-21 10:09:41

阅读数:272

评论数:0

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