拓扑 前缀 线性leetcode

LeetCode 658. Find K Closest Elements 二分+双指针

Given a sorted integer array `arr`, two integers `k` and `x`, return the `k` closest integers to `x` in the array. The result should also be sorted in ......
指针 LeetCode Elements Closest Find

LeetCode -- 870. 优势洗牌

贪心:这种最大化类似于田忌赛马。 每次取出nums1中最小的,和nums2进行比较,如果打得过,就打;打不过就用当前最小的和nums2中最大的换掉 c ++ class Solution { public: vector<int> advantageCount(vector<int>& nums1, ......
LeetCode 优势 870

abc089 <前缀和>

### 题目 [D - Practical Skill Test](https://atcoder.jp/contests/abc089/tasks/abc089_d) ### 思路 - 计算出所有结点在跳转过程中的前缀和, 从而O1查询 - 根据数据范围, 实际上不需要二分, 直接开相同大小的数组 ......
前缀 abc 089 lt gt

「前缀和」k倍区间

> 本题蓝桥OJ[第97题](https://www.lanqiao.cn/problems/97/learning)的题解(蓝桥OJ上的相同题解也是我发的) ## 题面 ### 题目描述 给定一个长度为N的数列,$A_1,A_2,\dots ,A_N$ ,如果其中一段连续的子序列 $A_i,A_{ ......
前缀 区间

abc086d <二维前缀和 同余>

### 题目 [D - Checker](https://atcoder.jp/contests/abc086/tasks/arc089_b) ### 思路 - 坐标对 2k 取余, 通过二维前缀和计算满足条件的个数; - 也可对 k 取余, [参考](https://www.luogu.com.c ......
前缀 086d abc 086 lt

leetcode刷题记录Java

``` 难度等级:简单 给你两个字符串 word1 和 word2 。请你从 word1 开始,通过交替添加字母来合并字符串。 如果一个字符串比另一个字符串长,就将多出来的字母追加到合并后字符串的末尾。 返回 合并后的字符串 。 class Solution { public String merg ......
leetcode Java

leetcode刷题记录(C语言)

``` 给你两个字符串 word1 和 word2 。请你从 word1 开始,通过交替添加字母来合并字符串。 如果一个字符串比另一个字符串长,就将多出来的字母追加到合并后字符串的末尾。 返回 合并后的字符串 。 输入:word1 = "abc", word2 = "pqr" 输出:"apbqcr" ......
leetcode 语言

abc084d <素数筛 前缀和>

### 题目 [D - 2017-like Number](https://atcoder.jp/contests/abc084/tasks/abc084_d) ### 思路 - 筛出数据范围`1e5`范围内的素数 - 检查每个素数是否为 2017-like - 对`1~1e5`内的2017-lik ......
素数 前缀 084d abc 084

Leetcode283. 移动零

``` class Solution { public: void moveZeroes(vector& nums) { if(nums.empty()) return; int n=nums.size(); int idx=n-1; while(idx>=0&&nums[idx]==0) idx- ......
Leetcode 283

Leetcode240.搜索二维矩阵II

``` class Solution { public: bool searchMatrix(vector>& matrix, int target) { if(matrix.empty()||matrix[0].empty()) return false; int n=matrix.size(), ......
矩阵 Leetcode 240

线性筛

## 引入 线性筛,通常用于筛积性函数 ## 线性筛素数 ```c++ inline void init(int n) { memset(IsPrime, true, sizeof(IsPrime)); tot = 0; IsPrime[1] = false; for (int i = 2; i < ......
线性

[LeetCode] 1218. Longest Arithmetic Subsequence of Given Difference

Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that th ......

LeetCode 354. Russian Doll Envelopes 排序+LIS

You are given a 2D array of integers `envelopes` where `envelopes[i] = [wi, hi]` represents the width and the height of an envelope. One envelope can ......
Envelopes LeetCode Russian Doll 354

LeetCode 519. Random Flip Matrix 哈希Map

There is an `m x n` binary grid matrix with all the values set 0 initially. Design an algorithm to randomly pick an index `(i, j)` where `matrix[i][j] ......
LeetCode Random Matrix Flip 519

数据结构之线性表

线性表的定义和操作 线性表的定义 线性表是具有相同数据类型的n(n>=0)个数据元素的有限序列,其中n为表长,当n=0时线性表是一个空表。若用L命名线性表,则其一般表示为 L = (a1,a2,...ai,ai+1,...an) 几个概念: 相同是指每个数据元素所占空间一样大。 ai 是线性表中的 ......
数据结构 线性 结构 数据

算法——前缀和 + 两数相加、相减

求数组中,连续区间的大小,可使用前缀和相减得到。 进阶变形 若想得到区间大小等于target,暴力枚举 前缀和相减。复杂度O(n^2) 优化算法:将每次求得的前缀和放入hashMap中,S[j] - S[i] == target,(j>i) 求出S[j]后,判断hashMap中是否存在 S[i] = ......
前缀 算法

LeetCode 239. 滑动窗口最大值

``` class Solution { public: vector maxSlidingWindow(vector& nums, int k) { deque q; vector res; for(int i=0;i=k) q.pop_front(); //插入新元素 while(q.size( ......
最大值 LeetCode 239

183_Power BI 折线图之平滑线性类型

# 183\_Power BI 折线图之平滑线性类型 ## 一、背景 曾几何时,为了在 Power BI 让折线图显示出平滑曲线,各路大佬是尽显神通。如今时间来到 2023 年 7 月,刚刚更新的 Power BI 已经支持折线图的平滑曲线。让我们来看看最终效果。 ![图-01](https://i ......
线图 线性 类型 Power 183

最左前缀匹配原则

最左前缀匹配原则:在MySQL建立联合索引时会遵守最左前缀匹配原则,即最左优先,在检索数据时从联合索引的最左边开始匹配。 要想理解联合索引的最左匹配原则,先来理解下索引的底层原理。索引的底层是一颗B+树,那么联合索引的底层也就是一颗B+树,只不过联合索引的B+树节点中存储的是键值。由于构建一棵B+树 ......
前缀 原则

线性基小记

设有数集 $S$,数的二进制表示最高位不超过 $K$.可构造线性基为一最小化的集合 $V$,满足一个数能被表示成若干 $S$ 中的数的异或和,当且仅当其能被表示成若干个 $V$ 中的数的异或和.$V$ 的大小不超过 $K+1$. ### 1 构造方法. 记 $V_i$ 表示线性基中最高位为 $i$ ......
小记 线性

ABC222D-Between Two Arrays(前缀和优化dp)

题意:给定两个递增数列A和B,构造一个ai <= ci <= bi 的递增数列C,询问满足条件的C的个数。 普通dp会超时,用前缀和优化 n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) ......
前缀 D-Between Between Arrays ABC

LeetCode 剑指 Offer 13. 机器人的运动范围

#题目链接:[LeetCode 剑指 Offer 13. 机器人的运动范围](https://leetcode.cn/problems/ji-qi-ren-de-yun-dong-fan-wei-lcof/) ##题意: **地上有一个m行n列的方格,从坐标 [0,0] 到坐标 [m-1,n-1] ......
机器人 LeetCode 范围 机器 Offer

Dircliet-前缀和

title: Dircliet 前缀和 feature: false mathjax: true date: 2022-07-28 15:29:51 tags: 数论 categories: Math cover: https://pic.imgdb.cn/item/62e23b7cf54cd3f9 ......
前缀 Dircliet

狄利克雷卷积前缀和

title: 狄利克雷卷积前缀和 feature: false mathjax: true date: 2022-09-08 10:16:23 tags: - 数论 categories: Math cover: https://pic.imgdb.cn/item/63195ceb16f2c2beb ......
卷积 前缀

线性相关性、线性表示、秩

@[toc] # 一、线性相关性 ## 1. 定义 **(1)线性相关**:设 $\alpha_1,\alpha_2,...,\alpha_s$ 是 $n$ 维向量,若 $\exist$ 不全为 $0$ 的一组数 $k_1,k_2,...,k_s$,使得 $k_1\alpha_1 + k_2\alp ......
线性 相关性

机器学习一 解析解方法求解线性回归_用解析法对线性回归实例求解

机器学习一 解析解方法求解线性回归_用解析法对线性回归实例求解_Starry-sky(jing)的博客-CSDN博客 更正博客中一处求导公式: ......
线性 实例 机器 方法

@ConfigurationProperties 前缀注入属性

import java.util.LinkedHashMap; import java.util.Map; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springfra ......
前缀 ConfigurationProperties 属性

线性代数1 行列式

#### (1)行列式的概念 行列式是一个**数值**,是**不同行不同列**元素乘积的**代数和** ![image](https://img2023.cnblogs.com/blog/3213233/202307/3213233-20230713163634839-1062534922.jpg) ......
行列式 线性代数 代数 线性 行列

leetcode day2 977 209 59

[toc] #977 ##暴力法 直接数组中每个元素平方后用sort进行排序 ##双指针法 数组是有序的,平方后最大的元素存在于nums的两端,所以就定义两个指向两端的指针, 然后比较两端绝对值的大小,大的加入新定义的ans数组,并且指针向内移动 ``` vector ans (nums.size( ......
leetcode day2 day 977 209

Leetcode238. 除自身以外数组的乘积

``` class Solution { public: vector productExceptSelf(vector& nums) { vector q; int t=1; for(auto i:nums) { q.push_back(t); t*=i; } t=1; for(int i=num ......
乘积 数组 Leetcode 238