Construct Binary Tree from Preorder and Inorder Traversal

2019-01-10
阅读 2 分钟
1.3k
Given preorder and inorder traversal of a tree, construct the binary tree.

leetcode 148 Sort List

2019-01-10
阅读 3 分钟
1.4k
Sort a linked list in O(n log n) time using constant space complexity.

raft分布式一致性协议

2017-09-13
阅读 1 分钟
2.8k
分布式一致性协议通俗讲就是多机状态的一致性保障协议,即如果同一份状态存储在多台机器上,如何保证在多台机器上的状态彼此是一致的。一致是指读到的结果和写入的预期是一致的。

【百度之星2017】资格赛-题3-度度熊与邪恶大魔王

2017-08-16
阅读 5 分钟
1.6k
当然,如果度度熊使用第i个技能打在第j个怪兽上面的话,会使得第j个怪兽的生命值减少p[i]-b[j],当然如果伤害小于防御,那么攻击就不会奏效。

【leetcode】146. LRU Cache LRU淘汰规则的kv hash容器

2017-02-08
阅读 2 分钟
2.3k
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put.

【leetcode】191. Number of 1 Bits 正整数中的bit位为1的个数

2016-11-15
阅读 1 分钟
2.4k
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).

【leetcode】刷题暂告一个段落

2016-11-14
阅读 1 分钟
3.4k
近一年没有写代码了,手痒无聊,集中刷了近一百题,前一半按序全部做了,后面的挑了有意思的做,一眼看起来太简单的且重复类型的就忽略了。最近挑的题,发现没有了自测按钮,不太方便。暂时不再刷题了。开启新的一章,学习“机器学习”,从入门开始,看书、上公开课、做题练习、做笔记。

【leetcode】127. Word Ladder 等长字符串集合的A到B的转移最短长度

2016-11-14
阅读 3 分钟
2.1k
Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such that:

【leetcode】104. Maximum Depth of Binary Tree

2016-11-11
阅读 1 分钟
2.7k
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

【leetcode】102. Binary Tree Level Order Traversal 水平遍历二叉树

2016-11-11
阅读 2 分钟
2.4k
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).

【leetcode】101. Symmetric Tree 二叉树是否是镜像结构

2016-11-11
阅读 1 分钟
3k
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).

【leetcode】99. Recover Binary Search Tree 复原有两个节点交换后的二叉排序树

2016-11-11
阅读 2 分钟
2.8k
Note:A solution using O(n) space is pretty straight forward. Could you devise a constant space solution?

【leetcode】100. Same Tree

2016-11-10
阅读 1 分钟
2.6k
Given two binary trees, write a function to check if they are equal or not.

【leetcode】98. Validate Binary Search Tree 二叉树是否是中序有序的

2016-11-10
阅读 2 分钟
3.6k
Given a binary tree, determine if it is a valid binary search tree (BST).

【leetcode】97. Interleaving String 字符串c是否是字符串a、b的交叉结果

2016-11-10
阅读 2 分钟
2.7k
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.

【leetcode】96. Unique Binary Search Trees

2016-11-10
阅读 1 分钟
2.2k
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?

【leetcode】95. Unique Binary Search Trees II 含有N个节点的中序遍历有序的二叉树集

2016-11-10
阅读 2 分钟
4.1k
Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n.

【leetcode】94. Binary Tree Inorder Traversal 二叉树的中序遍历

2016-11-10
阅读 3 分钟
2k
Given a binary tree, return the inorder traversal of its nodes' values.

【leetcode】93. Restore IP Addresses 无分隔符字符串ip形式的可表示的所有合法ip集合

2016-11-09
阅读 3 分钟
2.4k
Given a string containing only digits, restore it by returning all possible valid IP address combinations.

【leetcode】91. Decode Ways A-Z的字母表示1-26的数字,反向破解多少种字符串的可能性

2016-11-08
阅读 3 分钟
3.4k
A message containing letters from A-Z is being encoded to numbers using the following mapping:

【leetcode】90. Subsets II 有重复元素集合的所有组合形式

2016-11-08
阅读 2 分钟
3.2k
Given a collection of integers that might contain duplicates, nums, return all possible subsets.

【leetcode】88. Merge Sorted Array 有序数组的merge

2016-11-08
阅读 1 分钟
1.7k
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.

【leetcode】87. Scramble String 字符串树形颠倒匹配

2016-11-08
阅读 3 分钟
3.5k
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.

【leetcode】85. Maximal Rectangle 0/1矩阵的最大全1子矩阵

2016-11-07
阅读 3 分钟
5.4k
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.

【leetcode】84. Largest Rectangle in Histogram 最大面积的覆盖矩阵

2016-11-07
阅读 2 分钟
4.9k
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.

【leetcode】77. Combinations C(n,k)的所有组合形式

2016-11-07
阅读 2 分钟
4.6k
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.

【leetcode】76. Minimum Window Substring 最小字符包含给定字符串的子串

2016-11-07
阅读 3 分钟
3.8k
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).

【leetcode】75. Sort Colors 三颜色的数组排序后同颜色的相邻

2016-11-07
阅读 1 分钟
1.9k
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.

【leetcode】73. Set Matrix Zeroes 矩阵为0的位的行、列原地都置为0

2016-11-07
阅读 2 分钟
2.2k
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.

【leetcode】72. Edit Distance 编辑距离计算

2016-11-07
阅读 1 分钟
2.7k
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)