leetcode 45 ii

代码随想录算法训练营第三十七天| 121. 买卖股票的最佳时机 122.买卖股票的最佳时机II

121. 买卖股票的最佳时机 要求: [7,1,5,3,6,4]在里面找出合适的买入和卖出的时机 思路: 找到最小值和最大值,直接做差,但是需要保证顺序 贪心算法: 巧妙之处: 每一个节点都要比对是否是最小节点,然后跟最小节点进行相减,看是否是最大值 代码: int maxProfit(vector ......
时机 随想录 股票 训练营 随想

[LeetCode] 2208. Minimum Operations to Halve Array Sum

You are given an array nums of positive integers. In one operation, you can choose any number from nums and reduce it to exactly half the number. (Not ......
Operations LeetCode Minimum Halve Array

leetcode第354场周赛 2 - 双指针

[题目传送门](https://leetcode.cn/contest/weekly-contest-354/) # [2779. 数组的最大美丽值](https://leetcode.cn/problems/maximum-beauty-of-an-array-after-applying-ope ......
指针 leetcode 354

LeetCode 热题 100 之 21. 合并两个有序链表

# 题目 将两个升序链表合并为一个新的 升序 链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 **示例 1:** 输入:l1 = [1,2,4], l2 = [1,3,4] 输出:[1,1,2,3,4,4] **示例 2:** 输入:l1 = [], l2 = [] 输出:[] **示 ......
LeetCode 两个 100 21

LeetCode 热题 100 之 560. 和为 K 的子数组.md

# 题目 给你一个整数数组 nums 和一个整数 k ,请你统计并返回 该数组中和为 k 的连续子数组的个数 。 **示例 1:** 输入:nums = [1,1,1], k = 2 输出:2 **示例 2:** 输入:nums = [1,2,3], k = 3 输出:2 **提示:** 1 int ......
数组 LeetCode 100 560 md

[Leetcode Weekly Contest]355

链接:[LeetCode](https://leetcode-cn.com/contest/weekly-contest-355/) ## [Leetcode]6921. 按分隔符拆分字符串 给你一个字符串数组 words 和一个字符 separator ,请你按 separator 拆分 word ......
Leetcode Contest Weekly 355

LeetCode 热题 100 之 438. 找到字符串中所有字母异位词

# 题目 给定两个字符串 s 和 p,找到 s 中所有 p 的 异位词 的子串,返回这些子串的起始索引。不考虑答案输出的顺序。 异位词 指由相同字母重排列形成的字符串(包括相同的字符串)。 **示例 1:** 输入: s = "cbaebabacd", p = "abc" 输出: [0,6] 解释: ......
字符串 字母 字符 LeetCode 100

LeetCode 热题 100 之 3. 无重复字符的最长子串

# 题目 给定一个字符串 s ,请你找出其中不含有重复字符的 最长子串 的长度。 示例 1: 输入: s = "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。 示例 2: 输入: s = "bbbbb" 输出: 1 解释: 因为无重复字符的最长子串 ......
字符 LeetCode 100

LeetCode 399. 除法求值

``` class Solution { public: vector calcEquation(vector>& equations, vector& values, vector>& queries) { unordered_set node;//记录所有节点 unordered_map> g; ......
除法 LeetCode 399

代码随想录算法训练营第三十六天| 198.打家劫舍 213.打家劫舍II 337.打家劫舍III

198.打家劫舍 要求: 给定一个nums,要求取得最大值,但是不可以选择两个相邻的数 dp定义: dp[n],取到第N个数字的时候,最大值 递推公式: 取:nums[i] + dp[j-2] 不取: nums[i-1]; 代码: 1 // 在两个数字不相邻的情况下,得到的最大金额 2 // 思路: ......

LeetCode 周赛上分之旅 #34 按部就班地解决动态规划问题

> ⭐️ **本文已收录到 AndroidFamily,技术和职场问题,请关注公众号 [彭旭锐] 和 [BaguTree Pro] 知识星球提问。** > > 学习数据结构与算法的关键在于掌握问题背后的算法思维框架,你的思考越抽象,它能覆盖的问题域就越广,理解难度也更复杂。在这个专栏里,小彭与你分享 ......
按部就班 LeetCode 之旅 动态 问题

LeetCode 周赛上分之旅 #35 两题坐牢,菜鸡现出原形

> ⭐️ **本文已收录到 AndroidFamily,技术和职场问题,请关注公众号 [彭旭锐] 和 [BaguTree Pro] 知识星球提问。** > > 学习数据结构与算法的关键在于掌握问题背后的算法思维框架,你的思考越抽象,它能覆盖的问题域就越广,理解难度也更复杂。在这个专栏里,小彭与你分享 ......
原形 LeetCode 之旅 35

leetcode第109场双周赛

[题目传送门](https://leetcode.cn/contest/biweekly-contest-109/) # [6931. 访问数组中的位置使分数最大](https://leetcode.cn/problems/visit-array-positions-to-maximize-scor ......
leetcode 109

LeetCode 438. Find All Anagrams in a String 滑动窗口

Given two strings `s` and `p`, return an array of all the start indices of `p`'s anagrams in s. You may return the answer in any order. An Anagram is ......
LeetCode Anagrams String Find 438

leetcode第 109 场双周赛

## [6930. 检查数组是否是好的 - 力扣(LeetCode)](https://leetcode.cn/problems/check-if-array-is-good/) **首先判断数组长度是不是最大值 + 1, 然后排个序,判断0到n - 2是不是都是1到最大值的一个排列,满足这些返回t ......
leetcode 109

【优先队列】【堆排序实现优先队列】[1054. 距离相等的条形码](https://leetcode.cn/problems/distant-barcodes/)

#### 【优先队列】【堆排序实现优先队列】[1054. 距离相等的条形码](https://leetcode.cn/problems/distant-barcodes/) 在一个仓库里,有一排条形码,其中第 i 个条形码为 barcodes[i]。 请你重新排列这些条形码,使其中任意两个相邻的条形 ......

[LeetCode] 894. All Possible Full Binary Trees

Given an integer n, return a list of all possible full binary trees with n nodes. Each node of each tree in the answer must have Node.val == 0. Each e ......
LeetCode Possible Binary Trees Full

LeetCode 3. Longest Substring Without Repeating Characters 滑动窗口

Given a string `s`, find the length of the longest substring without repeating characters. ## Solution 用一个 $dict$ 来映射字符的次数。然后用 $left$, $right$ 来决定wind ......

leetcode-2582-easy

Pass the Pillow ``` There are n people standing in a line labeled from 1 to n. The first person in the line is holding a pillow initially. Every secon ......
leetcode 2582 easy

Leetcode394. 字符串解码

``` class Solution { public: string dfs(string s,int &idx) { string str; while(idx'0'&&s[idx]='0'&&s[idx]<='9') num+=s[idx++]; if(s[idx]=='[') { int c ......
字符串 字符 Leetcode 394

leetcode 栈与队列 232 225

[toc] #基本介绍 栈,先进后出 队列,先进先出 ##四个问题 1. C++中stack 是容器么? 2. 我们使用的stack是属于哪个版本的STL? 3. 我们使用的STL中stack是如何实现的? 4. stack 提供迭代器来遍历stack空间么? 首先大家要知道 栈和队列是STL(C+ ......
队列 leetcode 232 225

Silverlight工作流控件功能缺失,Windows Server操作系统 IIS添加WCF功能

**注:** Silverlight工作流控件,如果在网页中打不开,则要判断是否缺少`Silverlight工作流控件`的插件程序,如果不是则可以进行一下步骤检查,如果是以下原因则是:由于IIS版本问题,安装后可能出现不支持wcf服务的请求处理,需要手动添加处理程序;数据库客户端如果是64位,需要修 ......
功能 工作流 缺失 控件 Silverlight

[LeetCode] 1349. Maximum Students Taking Exam 参加考试的最大学生数

Given a `m * n` matrix `seats` that represent seats distributions in a classroom. If a seat is broken, it is denoted by `'#'` character otherwise it i ......
LeetCode Students Maximum Taking 学生

codility 和 leetcode 对比

根据网上的信息,codility 和 leetcode 都是用于评估编程技能的在线平台,它们都提供了不同难度和类型的编程挑战,支持多种编程语言,并可以用于招聘和面试的过程中。 不过,它们也有一些区别,比如: codility 更专注于工程团队的技能评估,它提供了 CodeCheck, CodeLiv ......
codility leetcode

leetcode872叶相似树

这道题是考虑的深度优先搜索,使用递归 vecotr和queue入队操作并不相同: vector只能使用push_back(); queue既可以使用push()还可以使用push_back() void FindLeaf(TreeNode* root,vector<int>& v){ if(!roo ......
leetcode 872

LeetCode 347. 前 K 个高频元素

# 快排思想 - 注意,这里是倒序排序,因此应该`while(nums[i].cnt>x);` ``` class Solution { public: struct element { int val,cnt; element(int a,int b) { val=a; cnt=b; } }; v ......
LeetCode 元素 347

LeetCode -- 773. 滑动谜题

启发式搜索 class Solution { struct Node { string str; int x, y; int val; }; int n = 2, m = 3; string e = "123450"; int dx[4] = {-1, 0, 1, 0}; int dy[4] = { ......
LeetCode 773

[LeetCode] 2297. Jump Game VIII

You are given a 0-indexed integer array nums of length n. You are initially standing at index 0. You can jump from index i to index j where i < j if: ......
LeetCode 2297 Jump Game VIII

leetcode 28 459 总结 KMP算法

[toc] #28 ##解法一,暴力法 ``` //暴力 if(haystack.length() pi(m); for (int i = 1, j = 0; i 0 && needle[i] != needle[j]) { j = pi[j - 1]; } if (needle[i] == nee ......
算法 leetcode 459 KMP 28

[LeetCode] 2408. Design SQL

You are given n tables represented with two arrays names and columns, where names[i] is the name of the ith table and columns[i] is the number of colu ......
LeetCode Design 2408 SQL