leetcode two sum

[USACO23FEB] Equal Sum Subarrays G 题解

[USACO23FEB] Equal Sum Subarrays G 题解 题目链接 \(O(n^5)\) 暴力 显然,如果修改 \(a_i\) 的值,只会影响包含 \(a_i\) 的区间的区间和。于是对于每个 \(a_i\),可以将所有区间分成两类,即包含 \(a_i\) 的区间和不包含 \(a_ ......
题解 Subarrays USACO Equal FEB

[LeetCode] 2785. Sort Vowels in a String

Given a 0-indexed string s, permute s to get a new string t such that: All consonants remain in their original places. More formally, if there is an i ......
LeetCode Vowels String 2785 Sort

[LeetCode] 1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance

There are n cities numbered from 0 to n-1. Given the array edges where edges[i] = [fromi, toi, weighti] represents a bidirectional and weighted edge b ......
the Neighbors Threshold LeetCode Distance

CodeForces 1452E Two Editorials

洛谷传送门 CF 传送门 考虑枚举其中一个区间取 \([i, i + K - 1]\),考虑对于每个 \(j\) 一次性处理出,区间取 \([j - K + 1, j]\) 多产生的贡献(即以 \(j\) 为右端点)。 对于一个 \([l_k, r_k]\),设其与 \([i, i + K - 1] ......
CodeForces Editorials 1452E 1452 Two

[题解] ABC282Ex Min + Sum

Min + Sum 给你两个序列 \(a\)、\(b\) 和 \(S\),求满足一下条件的区间 \([l ,r]\) 的数量: \(\sum_{i = l}^r b_i + \min_{i = l}^r a_i \le S\)。 \(n \le 2 \times 10^5\)。 考虑按最小值分治,即 ......
题解 ABC 282 Min Sum

[ARC092F] Two Faced Edges 题解

题意 给定一张有向图,询问将每条有向边反向过后整个图的强连通分量的个数是否发生改变。 数据范围:$n\le 1000,m\le 200000$。 思路 分类讨论,讨论强连通分量是增加了还是减少了,假设修改的边是 $u\to v$。 强连通分量减少 因为只修改了一条边,所以强连通分量减少的情况肯定是 ......
题解 Faced Edges 092F ARC

USB(2.0 / Type-C) to MPSSE(JTAG / SPI / IIC) / UART / FIFO: FTDI 的FT4232H配成SPI+JTAG+Two Ways UART使用实例

Ti60 Demo板FT4232H 串口使用 易灵思FPGA技术交流 2022-04-15 08:43 Ti60 F225 demo板使用的是FT4232H,有4个通道A,B,C和D。其中A通道用于SPI接口,可以是AS也可以是PS。通道B用于JTAG,通道C连接了UART,通道D连接了FX3。 A ......
JTAG UART SPI 实例 Type-C

[Leetcode] 0836. 矩形重叠

836. 矩形重叠 English Version 题目描述 矩形以列表 [x1, y1, x2, y2] 的形式表示,其中 (x1, y1) 为左下角的坐标,(x2, y2) 是右上角的坐标。矩形的上下边平行于 x 轴,左右边平行于 y 轴。 如果相交的面积为 正 ,则称两矩形重叠。需要明确的是, ......
矩形 Leetcode 0836

LeetCode 第 115 场双周赛

2899. 上一个遍历的整数 感觉读题比较困难 class Solution { public: vector<int> lastVisitedIntegers(vector<string>& words) { vector<int> res , a ; for( int i = 0 , cnt = ......
LeetCode 115

LeetCode -- 第 371 场周赛(哈希表,tire字典树)

class Solution { public: vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) { int n = access_times.size(); vector<string> re ......
字典 LeetCode tire 371

leetcode hot100-02 字母异位词分组

题目:字母异位词分组 难度:中等 地址:https://leetcode.cn/classic/problems/group-anagrams/description/ 描述:给你一个字符串数组,请你将 字母异位词 组合在一起。可以按任意顺序返回结果列表。字母异位词 是由重新排列源单词的所有字母得到 ......
字母 leetcode hot 100

leetcode hot 100-01 两数之和

题目:两数之和 难度:简单 题目地址:https://leetcode.cn/classic/problems/two-sum/description/ 过程一,因为难度是简单,就没有仔细审题,以为返回两个数就好,使用双指针,逻辑如下: 对数组排序 双指针分别指向头和尾 两数之和大于target,尾 ......
之和 leetcode hot 100

[LeetCode] 1360. Number of Days Between Two Dates 日期之间隔几天

Write a program to count the number of days between two dates. The two dates are given as strings, their format is YYYY-MM-DD as shown in the examples ......
LeetCode 之间 日期 Between Number

CF1485F Copy or Prefix Sum 题解

思路 考虑 \(a_i\) 要么是 \(b_i\) 要么是 \(b_i - s\)。 考虑 \(s\) 代表着什么。 它是 \(a\) 的前缀和。 那么必然是往前一段 \(b\) 的和。 因为每个 \(b\) 代表着要么是这一位的 \(a\) 或者前面所有的 \(a\)。 考虑设 \(f_i\) 为 ......
题解 Prefix 1485F 1485 Copy

Leetcode133.克隆图

需要注意图中存在环路。 JAVA: public final Node cloneGraph(Node node) { return deepCopy(node, new HashMap<Integer, Node>()); } private Node deepCopy(Node node, Ha ......
Leetcode 133

LeetCode450.删除二叉搜索树中的节点

题目描述 给定一个二叉搜索树的根节点 root 和一个值 key,删除二叉搜索树中的 key 对应的节点,并保证二叉搜索树的性质不变。返回二叉搜索树(有可能被更新)的根节点的引用。 一般来说,删除节点可分为两个步骤: 首先找到需要删除的节点; 如果找到了,删除它。 说明: 要求算法时间复杂度为 $O ......
节点 LeetCode 450

Memo Pack and LeetCode 3

Memo Pack Source code: git.suckless.org/sbase I don't know if it's the standard implementation for Linux bash command, but it's a good material. An ex ......
LeetCode Memo Pack and

Leetcode108. 将有序数组转换为二叉搜索树

因为数组是有序的,可以递归的选取根节点构建子树。 JAVA: public final TreeNode sortedArrayToBST(int[] nums) { if (null == nums) return null; return this.build(nums, 0, nums.len ......
数组 Leetcode 108

LeetCode #1131 Maximum of Absolute Value Expression 绝对值表达式的最大值

安装Flutter环境首先配置flutter3开发环境,照着官方教程傻瓜式安装即可。>>安装和环境配置 | Flutter 中文文档 | Flutter 中文开发者网站注意在国内网络环境下需要进行一些额外的环境配置:>>在中国网络环境下使用 Flutter | Flutter 中文文档 | Flut ......

LeetCode_0042. 接雨水

题目描述 给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。 示例 示例 1: 输入:height = [0,1,0,2,1,0,1,3,2,1,2,1] 输出:6 解释:上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图, ......
雨水 LeetCode 0042

leetcode322题解

今天来解析一下一道中等的leetcode题,题目如下: 给你一个整数数组 coins ,表示不同面额的硬币;以及一个整数 amount ,表示总金额。 计算并返回可以凑成总金额所需的 最少的硬币个数 。如果没有任何一种硬币组合能组成总金额,返回 -1 。 你可以认为每种硬币的数量是无限的。 示例 1 ......
题解 leetcode 322

『题解』CF213E - Two Permutations

Luogu CodeForces 首先数据范围是 \(2\mathrm{e}5\),支持枚举,问题留给了判断子序列。不简单想到了哈希,一开始想到的是树状数组,发现树状数组比较菜,就转向了线段树。 一开始先把 \(b\) 中的 \(1\sim n\) 加到线段树里,然后不断的删除最小的,加入最大的,这 ......
题解 Permutations 213E 213 Two

[LeetCode] 2849. Determine if a Cell Is Reachable at a Given Time

You are given four integers sx, sy, fx, fy, and a non-negative integer t. In an infinite 2D grid, you start at the cell (sx, sy). Each second, you mus ......
Determine Reachable LeetCode Given 2849

[LeetCode] 2609. Find the Longest Balanced Substring of a Binary String

You are given a binary string s consisting only of zeroes and ones. A substring of s is considered balanced if all zeroes are before ones and the numb ......
Substring LeetCode Balanced Longest Binary

LeetCode106. 从中序与后序遍历序列构造二叉树

题目描述 给定两个整数数组 inorder 和 postorder ,其中 inorder 是二叉树的中序遍历, postorder 是同一棵树的后序遍历,请你构造并返回这颗 二叉树 。 示例 提交的代码 思路: 轻喷,这种还是手写方便。 中序:左中右 后序:左右中 看我上面画的屎图,整棵树的根节点 ......
序列 从中 LeetCode 106

Two Types of Spells

贪心题,先假设全部都是w[i],然后你发现最多可以放电之咒个数的两倍,贪心加上这么多w[i](从大到小),但是你发现不能全是电之咒。 后面的限制不好用数据结构维护,考虑让数据结构维护的东西天然满足这个限制,那么直接删去一个电之咒然后选就行了。 那么肯定删去最小的电之咒。 维护的东西有: \[\sum ......
Spells Types Two of

LeetCode每日算法3—无重复字符的最长子串

题目描述 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。 示例 输入: s = "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。 解题思路 这个题目可以使用双指针+map来实现: 首先用双指针维护一个滑动窗口用来剪切子串 开始时, ......
算法 字符 LeetCode

LeetCode222.完全二叉树的节点个数

题目描述 给你一棵 完全二叉树 的根节点 root ,求出该树的节点个数。 完全二叉树 的定义如下:在完全二叉树中,除了最底层节点可能没填满外,其余每层节点数都达到最大值,并且最下面一层的节点都集中在该层最左边的若干位置。若最底层为第 h 层,则该层包含 1~ 2h 个节点。 示例 提交的代码 你被 ......
节点 个数 LeetCode 222

[Leetcode] 0119. 杨辉三角 II

119. 杨辉三角 II 题目描述 给定一个非负索引 rowIndex,返回「杨辉三角」的第 rowIndex 行。 在「杨辉三角」中,每个数是它左上方和右上方的数的和。 示例 1: 输入: rowIndex = 3 输出: [1,3,3,1] 示例 2: 输入: rowIndex = 0 输出: ......
杨辉三角 Leetcode 0119 II

[Leetcode] 0118. 杨辉三角

118. 杨辉三角 题目描述 给定一个非负整数 numRows,生成「杨辉三角」的前 numRows 行。 在「杨辉三角」中,每个数是它左上方和右上方的数的和。 示例 1: 输入: numRows = 5 输出: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]] 示 ......
杨辉三角 Leetcode 0118
共1840篇  :10/62页 首页上一页10下一页尾页