首页
控制台
留言板
分类
时间轴
关于我
Login
Menu
首页
控制台
留言板
分类
时间轴
关于我
十七
Archives
2022 / 02
leetcode61. 旋转链表
2022-02-23
leetcode
#链表
分析将链表首尾相连,得到循环链表,只需要尾指针向后移动n-k%n个就能得到移动后的首节点,此时下一个节点就是头节点,并将尾节点置空。/** * Definition for singly-linked list. * struct ListNode { * int val; * Li
leetcode60. 排列序列
2022-02-23
leetcode
#dfs
#困难
分析设置当前是第几个,如果到达第k个则结束循环。class Solution {public: int path[10]; bool st[10]; string s=""; int cur=0; void dfs(int n,int u,in
acwing59. 螺旋矩阵 II
2022-02-23
acwing
#图形
leetcdoe58. 最后一个单词的长度
2022-02-23
leetcode
#字符串
#简单
class Solution {public: int lengthOfLastWord(string s) { int ans=0,cur=s.length()-1; while(s[cur]==' '){ c
leetcode57. 插入区间
2022-02-22
leetcode
#区间合并
#中等
分析所有区间都是有序的,每个区间与合并区间有三种关系:1. 在区间左边2 在区间右边3 在区间中间,即有交集class Solution {public: vector<vector<int>> insert(vector<vector<int>>
acwing56. 合并区间
2022-02-22
acwing
#区间合并
class Solution {public: vector<vector<int>> merge(vector<vector<int>>& intervals) { vector<vector<
leetcode55. 跳跃游戏
2022-02-22
leetcode
#贪心
#中等
分析nums[i]是表示当前位置所能跳的最大步数,那么到达最远处之前的地方都能到达,此时再在这些位置跳过去,所以只需要看最远的位置是否能到达数组末尾。class Solution {public: bool canJump(vector<int>& nums) {
acwing125. 耍杂技的牛
2022-02-22
acwing
#贪心
acwing104. 货仓选址
2022-02-22
acwing
#贪心
分析中位数就是距离最近的点。#include<iostream>#include<algorithm>using namespace std;const int N=1e5+10;int a[N];int main(){ int n; cin>>n;
acwing913. 排队打水
2022-02-22
acwing
#贪心
Previous
32 / 43
Next