作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 解题方法 递归 迭代 日期 题目地址:https://leetcode.com/problems/binary-tree-inorder-traversal/ 题目描述 Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 递归+队列 栈 日期 题目地址:https://leetcode.com/problems/flatten-nested-list-iterator/description/ 题目描述 Given a nested list of integers, implement an iterator to flatten it. Each element i…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 递归 迭代 日期 题目地址:https://leetcode.com/problems/n-ary-tree-preorder-traversal/description/ 题目描述 Given an n-ary tree, return the preorder traversal of its nodes' values. For example,…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 迭代 递归 日期 题目地址:https://leetcode.com/problems/reverse-linked-list-ii/description/ 题目描述 Reverse a linked list from position m to n. Do it in one-pass. Note: 1 ≤ m ≤ n ≤ length of…
题目来源:https://leetcode.com/problems/time-based-key-value-store/description/ 标记难度:Medium 提交次数:1/1 代码效率:33.33%(212ms) 题意 给定一系列set和get操作,其中: 每个set操作包含一个key,一个value和一个timestamp,其中timestamp是严格递增的 每个get操作包含一个key和一个timestamp,要求找出与这个key相等且时间戳<=timestamp的set操作…
[LeetCode]449. Serialize and Deserialize BST 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/serialize-and-deserialize-bst/description/ 题目描述: Serialization is the process of converting a data structure or object into a sequence of bits s…
[LeetCode]692. Top K Frequent Words 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/top-k-frequent-words/description/ 题目描述: Given a non-empty list of words, return the k most frequent elements. Your answer should be sorted by frequency f…
[LeetCode]697. Degree of an Array 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/degree-of-an-array/description/ 题目描述: Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of…
[LeetCode]779. K-th Symbol in Grammar 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/k-th-symbol-in-grammar/description/ 题目描述: On the first row, we write a 0. Now in every subsequent row, we lo…
[LeetCode]792. Number of Matching Subsequences 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/number-of-matching-subsequences/description/ 题目描述: Given string S and a dictionary of words words,…
[LeetCode]881. Boats to Save People 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/boats-to-save-people/description/ 题目描述: The i-th person has weight people[i], and each boat can carry a maximu…
[LeetCode]802. Find Eventual Safe States 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/find-eventual-safe-states/description/ 题目描述: In a directed graph, we start at some node and every turn, w…
[LeetCode]813. Largest Sum of Averages 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/largest-sum-of-averages/description/ 题目描述: We partition a row of numbers A into at most…
[LeetCode]166. Fraction to Recurring Decimal 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/fraction-to-recurring-decimal/description/ 题目描述: Given two integers representing t…
[LeetCode]556. Next Greater Element III 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/next-greater-element-iii/description/ 题目描述: Given a positive 32-bit integer n, you need…
[LeetCode]522. Longest Uncommon Subsequence II 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/longest-uncommon-subsequence-ii/description/ 题目描述: Given a list of strings, you…
[LeetCode]880. Decoded String at Index 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/decoded-string-at-index/description/ 题目描述: An encoded string S is given. To find and wri…
[LeetCode]150. Evaluate Reverse Polish Notation 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/evaluate-reverse-polish-notation/description/ 题目描述: Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operator…
[LeetCode]222. Count Complete Tree Nodes 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.me/ 题目地址:https://leetcode.com/problems/count-complete-tree-nodes/description/ 题目描述: Given a complete binary tree, count the n…
[LeetCode]99. Recover Binary Search Tree 解题报告(Python) 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/recover-binary-search-tree/description/ 题目描述: Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without chan…
[LeetCode]592. Fraction Addition and Subtraction 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.me/ 题目地址:https://leetcode.com/problems/fraction-addition-and-subtraction/description/ 题目描述: Given a string representi…
Search in Rotated Sorted Array II Follow up for "LeetCode: Search in Rotated Sorted Array 解题报告":What if duplicates are allowed? Would this affect the run-time complexity? How and why? Write a function to determine if a given target is in the arr…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 Python解法 Java解法 日期 [LeetCode] 题目地址:https://leetcode.com/problems/implement-queue-using-stacks/ Total Accepted: 42648 Total Submissions: 125482 Difficulty: Easy 题目描述 Implement t…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典 日期 题目地址:https://leetcode.com/problems/time-based-key-value-store/ 题目描述 Create a timebased key-value store class TimeMap, that supports two operations. set(string key, string…
原题链接在这里:https://leetcode.com/problems/time-based-key-value-store/ 题目: Create a timebased key-value store class TimeMap, that supports two operations. 1. set(string key, string value, int timestamp) Stores the key and value, along with the given times…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 DFS BFS 日期 题目地址:https://leetcode.com/problems/cousins-in-binary-tree/ 题目描述 In a binary tree, the root node is at depth 0, and children of each depth k node are at depth k+1. Tw…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.com/problems/queue-reconstruction-by-height/#/description 题目描述 Suppose you have a random list of people standing in a queue. Each person is described b…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 递归 BST的中序遍历是有序的 日期 题目地址:https://leetcode.com/problems/validate-binary-search-tree/#/description 题目描述 Given a binary tree, determine if it is a valid binary search tree (BST). A…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 记忆化递归 动态规划 卡特兰数 日期 题目地址:https://leetcode.com/problems/unique-binary-search-trees/description/ 题目描述 Given n, how many structurally unique BST's (binary search trees) that store…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述: 题目大意 解题方法 自定义sorted函数的cmp 日期 题目地址:https://leetcode.com/problems/sort-array-by-parity/description/ 题目描述: Given an array A of non-negative integers, return an array consisting of all the…