码迷,mamicode.com
首页 >  
搜索关键字:leetcode 19    ( 34993个结果
Leetcode 829. 连续整数求和(C语言)
829. 连续整数求和 给定一个正整数 N,试求有多少组连续正整数满足所有数字之和为 N? 示例 1: 输入: 5 输出: 2 解释: 5 = 5 = 2 + 3,共有两组连续整数([5],[2,3])求和后为 5。 示例 2: 输入: 9 输出: 3 解释: 9 = 9 = 4 + 5 = 2 + ...
分类:编程语言   时间:2020-10-29 10:45:13    阅读次数:21
LeetCode 128. 最长连续序列
当我按照官方的思路写出代码,提交后并未通过,查看错误,发现算法错误的将[2147483647,-2147483648]也视为连续的整数了,这是因为我没有考虑到int类型的边界。将代码稍加修改,即成功提交 //哈希表,建议看官方的题解,尤其是演示动画 class Solution { public i ...
分类:其他好文   时间:2020-10-29 10:20:41    阅读次数:23
LeetCode 217. 存在重复元素
//通过哈希表来查重 class Solution { public boolean containsDuplicate(int[] nums) { Set<Integer> set = new HashSet<>(); for(int i = 0;i < nums.length;i++){ if( ...
分类:其他好文   时间:2020-10-29 10:06:06    阅读次数:17
回溯法4,排列问题,带条件
一.题源 https://www.lintcode.com/problem/permutations-ii/description https://leetcode-cn.com/problems/permutations-ii/ 二.代码分析 1 public class Solution { 2 ...
分类:其他好文   时间:2020-10-27 11:42:13    阅读次数:24
LeetCode 145. 二叉树的后序遍历
class Solution { public List<Integer> postorderTraversal(TreeNode root) { //一般解法,前序遍历后,翻转下结果集,注意下 与前序遍历的进栈顺序不一样 //(前序) 根左右 --> 变为 根右左 --> 翻转 左右根 (后续) ...
分类:其他好文   时间:2020-10-27 11:40:04    阅读次数:20
[LeetCode] 46. Permutations(全排列)
Difficulty: Medium Related Topics: Backtracking Link: https://leetcode.com/problems/permutations/ Description Given a collection of distinct integers, ...
分类:其他好文   时间:2020-10-27 10:57:46    阅读次数:22
[LeetCode] 406. Queue Reconstruction by Height(按身高重排队列)
Difficulty: Medium Related Topics: Greedy Link: https://leetcode.com/problems/queue-reconstruction-by-height/ Description Suppose you have a random li ...
分类:其他好文   时间:2020-10-27 10:54:44    阅读次数:28
Leetcode 95 Unique Binary Search Trees II
题目介绍 给定正整数n,利用1到n构造所有可能的二叉树,并返回。 Example: Input: 3 Output: [ [1,null,3,2], [3,2,null,1], [3,1,null,null,2], [2,1,3], [1,null,2,null,3] ] Explanation: ...
分类:其他好文   时间:2020-10-26 11:19:06    阅读次数:17
Leetcode 98 Validate Binary Search Tree
题目介绍 判断给定二叉树是否为一棵二叉搜索树。 Examples: 2 / \ 1 3 Input: [2,1,3] Output: true 5 / \ 1 4 / \ 3 6 Input: [5,1,4,null,null,3,6] Output: false Solution 仅仅使用递归判断 ...
分类:其他好文   时间:2020-10-26 11:18:28    阅读次数:24
Leetcode 114 Flatten Binary Tree to Linked List
题目介绍 给定二叉树,将其原地变成一个链表。 Example: 1 / \ 2 5 / \ \ 3 4 6 1 \ 2 \ 3 \ 4 \ 5 \ 6 Solutions 直观解法 发现链表的结果与先序遍历一致,因此先进行先序遍历,再根据遍历的结果构造链表。 # Definition for a b ...
分类:其他好文   时间:2020-10-26 11:17:57    阅读次数:15
34993条   上一页 1 ... 65 66 67 68 69 ... 3500 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!