码迷,mamicode.com
首页 >  
搜索关键字:solution upgrade    ( 13024个结果
20.1.3 86. 分隔链表
题目 给你一个链表和一个特定值 x ,请你对链表进行分隔,使得所有小于 x 的节点都出现在大于或等于 x 的节点之前。 你应当保留两个分区中每个节点的初始相对位置。 示例: 输入:head = 1->4->3->2->5->2, x = 3 输出:1->2->2->4->3->5 思路 思路很简单, ...
分类:其他好文   时间:2021-01-06 12:15:51    阅读次数:0
最长上升子序列
一步一步推导出官方最优解法,详细图解 上面这篇文章讲的很详细了。 ####300. 最长递增子序列 class Solution { public: int lengthOfLIS(vector<int>& nums) { vector<int> minList; for(auto& i : num ...
分类:其他好文   时间:2021-01-06 12:12:27    阅读次数:0
LeetCode 1019. 链表中的下一个更大节点
1019. 链表中的下一个更大节点 Difficulty: 中等 给出一个以头节点 head 作为第一个节点的链表。链表中的节点分别编号为:node_1, node_2, node_3, ... 。 每个节点都可能有下一个更大值(next larger value):对于 node_i,如果其 ne ...
分类:其他好文   时间:2021-01-06 11:50:22    阅读次数:0
LeetCode337. 打家劫舍 III
☆☆☆☆思路:树形DP问题。 class Solution { /** * 1.状态的定义:dp[node][j] 表示 node是否偷取所能获得的最大价值。 * j = 0, 表示node节点不偷 ; j = 1, 表示node结点偷取 * 2.状态转移方程: * 如果当前节点偷,那么左右子节点均 ...
分类:其他好文   时间:2021-01-06 11:44:45    阅读次数:0
Leetcode101.对称二叉树
题目 1 class Solution { 2 public: 3 4 bool isSymmetric(TreeNode* root) { 5 return check(root,root); 6 } 7 bool check(TreeNode* p,TreeNode* q) { 8 if(!p ...
分类:其他好文   时间:2021-01-05 11:37:37    阅读次数:0
Leetcode100.相同的树
题目描述 1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode() : val(0), ...
分类:其他好文   时间:2021-01-05 11:28:10    阅读次数:0
剑指 Offer 28. 对称的二叉树
剑指 Offer 28. 对称的二叉树 class Solution { public boolean isSymmetric(TreeNode root) { if(root == null) return true; return Just(root.left,root.right); } pu ...
分类:其他好文   时间:2021-01-05 11:27:06    阅读次数:0
Global Round 2 题解
$Global Round 2$题解 \(zhanglichen\ 2021.1.1\) \(A.Ilya\ and\ a\ Colorful\ Walk\) 给出一个数组,询问$2$个不相同的数字的最远距离。 \(Solution\) 做法有很多,刚开始来不及细想直接打了发线段树过的,$A$题上线 ...
分类:其他好文   时间:2021-01-05 11:23:08    阅读次数:0
LeetCode40. 组合总和 II
思路:回溯搜索 + 剪枝。 注意,回溯做选择的方法,不适用于有 “有重复元素的数组”。因此,重点掌握 常规回溯算法的写法。 class Solution { public List<List<Integer>> combinationSum2(int[] candidates, int target ...
分类:其他好文   时间:2021-01-01 12:54:26    阅读次数:0
迭代法 二叉树前序、中序、后序 遍历
前序 class Solution { public: vector<int> preorderTraversal(TreeNode* root) { vector<int> res; if (root == nullptr) { return res; } stack<TreeNode*> stk ...
分类:其他好文   时间:2021-01-01 12:36:16    阅读次数:0
13024条   上一页 1 ... 31 32 33 34 35 ... 1303 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!