频率leetcode 895
Leetcode 2. 两数相加
这道题让我想起了acwing里的高精度加法,因为这里的加法也是超过100位了。于是套着模板写了一下,然后看了一下评论区,发现链表再套vector属于是脱裤子放屁了 /** * Definition for singly-linked list. * struct ListNode { * int v ......
[C++]LeetCode1147. 段式回文
[C++]LeetCode1147. 段式回文 题目描述 Difficulty: 困难 Related Topics: 贪心, 双指针, 字符串, 动态规划, 哈希函数, 滚动哈希 你会得到一个字符串 text 。你应该把它分成 k 个子字符串 (subtext1, subtext2,…, subt ......
leetcode 197 上升的温度
上升的温度 date_add(interval expr type) 使用日期相加函数 select w1.id from Weather w1 left join Weather w2 on w1.recordDate = date_add(w2.recordDate, interval 1 da ......
leetcode 196 删除重复的电子邮箱
删除重复的电子邮箱 mysql 来说,inner join 是在做笛卡尔积 delete p1 from Person p1 inner join Person p2 on p1.email = p2.email and p1.Id > p2.Id delete p1 FROM person p1 ......
LeetCode 91. 解码方法
class Solution { public: int f[110]; bool check(char a,char b) { if(a>='1'&&a<='9'&&b>='0'&&b<='9') { int c=a-'0'; c=c*10+(b-'0'); if(c>=1&&c<=26) ret ......
LeetCode #453 最小操作次数使数组元素相等
基本思路 每次让数组的n-1个元素加1——等价于——每次让一个元素减1; 把所有数加到相同的最大值 ——等价于——把所有的数捡到最小值; 因此最小操作次数 = 数组所有元素之和 - ( 数组长度 * 最小值); 标程 1 class Solution { 2 public: 3 int minMov ......
leetcode 185
部门工资前三高的所有员工 select d.name as Department, e.name as Employee, e.salary as Salary from Employee e left join Department d on e.departmentId = d.Id where ......
LeetCode #448 找到所有数组中消失的数字
基本思路 为了满足题目要求的不使用额外的存储空间(当然返回的数组除外),并且时间复杂度控制在O(n),最多只能常数级别遍历,因此考虑将原数组视作一个"哈希表"。 遍历原数组,将【1,n】上的值域映射到【0,n-】的坐标上,某个数x扫描到一次则将这个数x映射的 x-1的坐标处的值加上n。 然后再次遍历 ......
LeetCode #283 移动零(双指针版本,效率高)
基本思路 思路————双指针 初始状态左右指针都指向数组首位元素,然后right指针开始迭代数组,当碰到非0元素则与左指针left所在位置的元素交换。 交换完毕后,左指针left则向前移动到下一位置,做好准备迎接下一个非0元素的交换。 这种算法效率比之前撰写的“伪双指针”效率更高,更能应对特殊情况。 ......
LeetCode #645 错误的集合
基本思路 用一个vector来模拟哈希表,记录每个元素的数量从而来找到重复的数和缺失的数。 标程 1 class Solution { 2 public: 3 vector<int> findErrorNums(vector<int>& nums) { 4 int n = nums.size(); ......
LeetCode #697 数组的度
基本思路 需要知道数组中某些元素的出现次数来寻求最大出现次数,以及要找到长度最短的子数组长度。 因此可以考虑使用哈希表来记录某个元素出现的次数,第一个元素出现的下表,最后一个元素出现的下标。映射关系:x-->{times,starti,endj}。 标程 1 class Solution { 2 p ......
LeetCode #414 第三大的数
解题思路数组从大到小排序后,从第2个元素开始遍历,如果与上一个元素不相同,则标志位++,标志位一旦从1加到3(两次)则代表存在第三大的数,即可返回。如若不存在第三大的数,则在遍历结束后,函数末尾返回数组的第一个元素(最大的元素)。 标程 1 class Solution { 2 public: 3 ......
LeetCode #485 最大连续 1 的个数
解题思路基础题,最后加一个特殊情况处理就好,时间复杂度O(n) 代码 class Solution {public: int findMaxConsecutiveOnes(vector<int>& nums) { int count=0; int Maxcount=0; for(int i =0; ......
4月11日leetcode练习
设计一个支持 push ,pop ,top 操作,并能在常数时间内检索到最小元素的栈。 实现 MinStack 类: MinStack() 初始化堆栈对象。void push(int val) 将元素val推入堆栈。void pop() 删除堆栈顶部的元素。int top() 获取堆栈顶部的元素。i ......
leetcode 184
部门工资最高的员工 select d.name as Department, e.name as Employee, e.salary as Salary from Employee e left join Department d on e.departmentId = d.id where (e ......
leetcode 183
从不订购的客户 select c.Name as Customers from Customers c left join Orders o on c.Id = o.CustomerId where o.CustomerId is null select customers.name custome ......
leetcode 182
查找重复的电子邮箱 select email as Email from Person group by email having count(email) > 1 select email as Email from ( select email ,count(email) as c from P ......
leetcode 181
超过经理收入的员工 select e1.name as Employee from Employee e1, Employee e2 where e1.managerId = e2.id and e1.salary > e2.salary select e1.name as Employee fro ......
【LeetCode回溯算法#extra01】集合划分问题【火柴拼正方形、划分k个相等子集、公平发饼干】
火柴拼正方形 https://leetcode.cn/problems/matchsticks-to-square/ 你将得到一个整数数组 matchsticks ,其中 matchsticks[i] 是第 i 个火柴棒的长度。你要用 所有的火柴棍 拼成一个正方形。你 不能折断 任何一根火柴棒,但你 ......
[LeetCode] 2390. Removing Stars From a String
You are given a string s, which contains stars *. In one operation, you can: Choose a star in s. Remove the closest non-star character to its left, as ......
leetcode 180
连续出现的数字 select distinct l1.num as ConsecutiveNums from Logs l1, Logs l2, Logs l3 where l1.id = l2.id - 1 and l2.id = l3.id - 1 and l1.num = l2.num and ......
leetcode_打卡1
leetcode_打卡1 题目:1768. 交替合并字符串 解答: 思路: 模拟即可,字符串的提取: a.charAt(i) class Solution { public String mergeAlternately(String word1, String word2) { String re ......
matlab调制解调 OFDM OTFS 16qam qpsk ldpc turbo在高斯白噪声,频率选择性衰落信道下的误比特率性能仿真
matlab调制解调 OFDM OTFS 16qam qpsk ldpc turbo在高斯白噪声,频率选择性衰落信道下的误比特率性能仿真,matlab代码 OFDM simulink 包括添加保护间隔(cp),信道均衡(ZF MMSE MRC MA LMSEE) 代码每行都有注释,适用于学习,附带仿 ......
leetcode 178
分数排名 select s1.score, count(distinct s2.score) as `rank` from Scores as s1, Scores as s2 where s1.score <= s2.score group by s1.id order by s1.score d ......
leetcode 177
第N高的薪水 CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT BEGIN declare T int default 0; SET T = N-1; RETURN ( # Write your MySQL query statement ......
LeetCode 959. 有斜杠划分区域
题目: https://leetcode.cn/problems/regions-cut-by-slashes/description/ 题解(参考了讨论区):将初始N*N的网格看做4 * N* N的三角形集合,根据输入合并对应的三角形。 C# 实现 public class Solution { ......
Leetcode(剑指offer专项训练)——DFS/BFS专项(3)
重建序列 题目 给定一个长度为 n 的整数数组 nums ,其中 nums 是范围为 [1,n] 的整数的排列。还提供了一个 2D 整数数组 sequences ,其中 sequences[i] 是 nums 的子序列。 检查 nums 是否是唯一的最短 超序列 。最短 超序列 是 长度最短 的序列 ......
LeetCode习题——x 的平方根(二分查找)
### x 的平方根 力扣链接:[x 的平方根 ](https://leetcode.cn/problems/sqrtx/) #### 题目 > 给你一个非负整数 x ,计算并返回 x 的 算术平方根 。>> 由于返回类型是整数,结果只保留 整数部分 ,小数部分将被 舍去 。>> 注意:不允许使用任 ......
【LeetCode动态规划#06】分割等和子集(01背包问题一维写法实战)
分割等和子集 分割等和子集 给你一个 只包含正整数 的 非空 数组 nums 。请你判断是否可以将这个数组分割成两个子集,使得两个子集的元素和相等。 示例 1: 输入:nums = [1,5,11,5] 输出:true 解释:数组可以分割成 [1, 5, 5] 和 [11] 示例 2: 输入:num ......