关闭
当前搜索:

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

Problem同样的代码在LeetCode上提交,在 python3解释器 下报错,换成 python2解释器 下却好好的: 在 StackOverflow 上找到了答案: 仔细对比了python解释器版本,LeetCode上面的python3解释器版本是3.5: 而本地anaconda3带的是python3.6解释器。尽管也属于python3.x,却并不报错: Summary简而言之就是,...
阅读(241) 评论(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 identical and the nodes have the same value.Example 1:In...
阅读(244) 评论(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 is pretty straight forward. Could you devise a cons...
阅读(260) 评论(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 nodes with keys less than the node’s key. The righ...
阅读(236) 评论(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”, return true. When s3 = “aadbbbaccc”, return fals...
阅读(231) 评论(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’s. 1 3 3 2 1 \ /...
阅读(185) 评论(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 should return all 5 unique BST’s shown below. 1...
阅读(185) 评论(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 return [1,3,2].Note: Recursive solution is trivial, cou...
阅读(200) 评论(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 [“255.255.11.135”, “255.255.111.35”]. (Order does not...
阅读(179) 评论(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,return 1->4->3->2->5->NULL.Note: Given m, n satisfy the following c...
阅读(176) 评论(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 encoded message containing digits, determine the total number of...
阅读(219) 评论(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 contain duplicate subsets.For example, If nums = [1,2,2...
阅读(203) 评论(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 number of bits in the code, print the sequence of gray...
阅读(243) 评论(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 that is greater or equal to m + n) to hold additiona...
阅读(219) 评论(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 representation of s1 = “great”: great / \ gr eat...
阅读(190) 评论(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 original relative order of the nodes in each of the...
阅读(196) 评论(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 the following matrix: # # 1 0 1 0 0 # 1 0 1 1 1 # 1...
阅读(192) 评论(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 in the histogram.# Above is a histogram where width...
阅读(189) 评论(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 1->1->2->3->3, return 1->2->3.AC# Definition for singly-linke...
阅读(195) 评论(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->2->3->3->4->4->5, return 1->2->5. Given 1->1->1->...
阅读(242) 评论(0)
102条 共6页1 2 3 4 5 ... 下一页 尾页
    Site Search
    Google 本站
    个人资料
    • 访问:181609次
    • 积分:6944
    • 等级:
    • 排名:第3972名
    • 原创:486篇
    • 转载:14篇
    • 译文:0篇
    • 评论:25条
    About
    博客专栏
    文章分类