Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the dep ...
分类:
其他好文 时间:
2019-09-25 12:15:45
阅读次数:
93
问题描述 Given a binary tree, return the inorder traversal of its nodes' values. (左 - 根 - 右) Example: Follow up: Recursive solution is trivial, could you ...
分类:
其他好文 时间:
2019-09-25 10:42:33
阅读次数:
71
①英文题目 Remove all elements from a linked list of integers that have value val. Example: ②中文题目 删除链表中等于给定值 val 的所有节点。 示例: ③思路 1、加入链表为空,那么直接返回head。 2、考虑6, ...
分类:
其他好文 时间:
2019-09-24 14:27:17
阅读次数:
93
Given a collection of distinct integers, return all possible permutations. Example: Solution 2: ...
分类:
其他好文 时间:
2019-09-22 23:11:46
阅读次数:
105
题目 Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in b ...
分类:
其他好文 时间:
2019-09-22 17:51:22
阅读次数:
91
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: ...
分类:
其他好文 时间:
2019-09-22 12:49:54
阅读次数:
71
Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. Exampl ...
分类:
其他好文 时间:
2019-09-22 10:40:08
阅读次数:
113
简直精妙。 哈夫曼编码? 我用的是dp,这种区间dp的时间复杂度是真的难算!状态转移方程为n的区间dp时间都算作n^3吧。 先把任务从长到短排序,然后看worker在那一层要细分多少?就是位置i和员工数n的dp转移。 但是可以贪心!!!!!!!!!!!!每次都是把时间最短的放在最后,而且这两个必然同 ...
分类:
其他好文 时间:
2019-09-22 10:36:43
阅读次数:
101
"题目描述" 思路 代码 c++ include include include include define min(a, b) ((a) = 2) cnt(r) , size(r) ; else if (!lc(r) || !rc(r)) r = lc(r) + rc(r); else if ( ...
分类:
其他好文 时间:
2019-09-18 17:52:28
阅读次数:
119
①中文题目 给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度。 不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O(1) 额外空间的条件下完成。 示例 1: 给定数组 nums = [1,1,2], 函数应该返回新的长度 2, 并且原数组 n ...
分类:
编程语言 时间:
2019-09-18 00:48:19
阅读次数:
100