leetcode winner array 1535
【11月LeetCode组队打卡】Task1--HashTable
217.存在重复元素 vector 向量的用法有点忘了,先简单回顾一下 (其实是好久没写cpp了(安详.jpg 输入与输出 //未知数组元素个数 vector<int> hash; int x; while(cin>>x){ hash.push_back(x); //遇到回车就停止输入 if(cin ......
Java Byte[] array 字节复制
原始的写法 String key = "abcdef0123456789"; keyBytes = key.getBytes(UTF_8); for (byte b : keyBytes) { char c = (char) b; System.out.print(c); } stream lamd ......
typeof 主要用于检测基本数据类型,对于引用类型不大适用(因为所有引用类型的值都是 Object 的实例),只能知道是对象,而具体是什么类型的对象却无法判断。这时需要 instanceof 来判断到底是什么类型(普通Object类型、Array类型、Function类型、RegExp类型、Date类型,基本包装类型【包括:Boolean、Number、String类型】)的对象
下面哪些语句可以 在JS里判断一个对象是否为String类型? A oStringObject instanceof String B typeof oStringObject == 'string' C oStringObject is String D 以上答案都不正确 正确答案:A JS 中值 ......
CodeForces 1895F Fancy Arrays
洛谷传送门 CF 传送门 看到题目感觉很怪,没有什么很好的直接做的办法。于是考虑容斥,\(\min a_i \le x + k - 1\) 的方案数减去 \(\max a_i < x\) 的方案数即为答案。 前者的方案数是好算的。注意到只要确定了 \(\min a_i\) 和差分数组 \(a_i - ......
LeetCode 刷题
LeetCode 刷题 577. 员工奖金【左连接: A left join B on...】 左连接后是一个新的表,后可以 + where 语句 # Write your MySQL query statement below select name, bonus from Employee le ......
Palindrome-less Arrays
here 哥们不会组合数学。 首先类似这题,得出没有回文串的充要条件是没有长度为 3 的回文串。 长度为 3 的回文串,\(a_i,a_{i+1},a_{i+2}\),只要满足 \(a_i \neq a_{i+2}\) 即可,也就是说奇数位、偶数位抠出来,新数组中相邻的数不相同。 考虑 dp,一种显 ......
[题解] CF1748E Yet Another Array Counting Problem
Yet Another Array Counting Problem 给你一个长度为 \(n\) 的序列和一个数 \(m\),求有多少个长度为 \(n\) 的序列 \(b\) 满足: \(\forall i \in [1, n], b_i \in [1, m]\)。 对于每个区间 \([l, r]\ ......
[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] 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 ......
[V8] Holey Arrays
What is holey array: an array with hole(s) const array = [1,2, ,3] Why this is a problem? Should array[2] to be undefined? Yes and no.. normally it is ......
[CF1895F] Fancy Arrays
先把存在性容斥一下。变成 \([0,\infty]\) 减去 \([0,x-1]\) 和 \([x+k,\infty]\)。 \([0,x-1]\) 的答案显然可以矩阵快速幂 \(\mathcal O(x^3\log n)\) 求。考虑剩下两个。注意到两个单拎出来都不好求,所以直接求这两个的差。 注 ......
[V8] Object & array copying
import { createBenchmark } from "./benchmark"; class MyArray extends Array {} const SIZE = 100; const obj: Record<string, number> = {}; /** * { * _0: ......
CF121E Lucky Array
sqrt technology, sqrt faith. 洛谷 CF 定义一个数为幸运数字,当且仅当其十进制数位中仅有 \(4\) 和 \(7\) 组成。 给出长度为 \(n\) 的序列 \(p_1\sim p_n\),有 \(q\) 次操作,分为两种类型: \(\texttt{add }l\tex ......
[Leetcode] 0836. 矩形重叠
836. 矩形重叠 English Version 题目描述 矩形以列表 [x1, y1, x2, y2] 的形式表示,其中 (x1, y1) 为左下角的坐标,(x2, y2) 是右上角的坐标。矩形的上下边平行于 x 轴,左右边平行于 y 轴。 如果相交的面积为 正 ,则称两矩形重叠。需要明确的是, ......
LeetCode 第 115 场双周赛
2899. 上一个遍历的整数 感觉读题比较困难 class Solution { public: vector<int> lastVisitedIntegers(vector<string>& words) { vector<int> res , a ; for( int i = 0 , cnt = ......
LeetCode -- 第 371 场周赛(哈希表,tire字典树)
class Solution { public: vector<string> findHighAccessEmployees(vector<vector<string>>& access_times) { int n = access_times.size(); vector<string> re ......
leetcode hot100-02 字母异位词分组
题目:字母异位词分组 难度:中等 地址:https://leetcode.cn/classic/problems/group-anagrams/description/ 描述:给你一个字符串数组,请你将 字母异位词 组合在一起。可以按任意顺序返回结果列表。字母异位词 是由重新排列源单词的所有字母得到 ......
leetcode hot 100-01 两数之和
题目:两数之和 难度:简单 题目地址:https://leetcode.cn/classic/problems/two-sum/description/ 过程一,因为难度是简单,就没有仔细审题,以为返回两个数就好,使用双指针,逻辑如下: 对数组排序 双指针分别指向头和尾 两数之和大于target,尾 ......
[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 ......
js中的内部对象包括Array、Boolean、Date、Function、Global、Math、Number、Object、RegExp、String以及各种错误类对象,包括Error、EvalError、RangeError、ReferenceError、SyntaxError和TypeError。
JS中,可以将对象分为“内部对象”、“宿主对象”和“自定义对象”三种。 1,内部对象 js中的内部对象包括Array、Boolean、Date、Function、Global、Math、Number、Object、RegExp、String以及各种错误类对象,包括Error、EvalError、Ra ......
C. Serval and Toxel's Arrays 组合数学
题目链接🔗 分析一下题意:给定一个初始数组A,以及m次操作,每一次操作会改变一个A中的数字,一共得到m+1个数组。 现在,要求出任意两个数组两两组合的情况中:所有的不重复数字出现次数的总和。 这道题想了很久,乍一看以为是模拟,手画递归找规律一直没想出来。看了题解思路,发现出发点就错了:因为每个数组 ......
以下哪些Array对象的方法不会更改原有数组?
以下哪些Array对象的方法不会更改原有数组? A concat() B splice() C map() D sort() 正确答案:AC 会改变数组的方法: push() pop() shift() unshift() splice() sort() reverse() forEach() 不会 ......
"+new Array(017)" 这段代码输出为 NaN
首先,前面+是一元运算符,相当于我们说的正负,无运算效果,但是可以将字符串等转为number类型。 此题中017其实是八进制,故而是是Array(15)。 这里相当于对于一个未赋值但是长度为15的数组进行number类型转化,其结果为NaN 八进制的17转为二进制:001111,再转为十进制的15( ......
Leetcode133.克隆图
需要注意图中存在环路。 JAVA: public final Node cloneGraph(Node node) { return deepCopy(node, new HashMap<Integer, Node>()); } private Node deepCopy(Node node, Ha ......
LeetCode450.删除二叉搜索树中的节点
题目描述 给定一个二叉搜索树的根节点 root 和一个值 key,删除二叉搜索树中的 key 对应的节点,并保证二叉搜索树的性质不变。返回二叉搜索树(有可能被更新)的根节点的引用。 一般来说,删除节点可分为两个步骤: 首先找到需要删除的节点; 如果找到了,删除它。 说明: 要求算法时间复杂度为 $O ......
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 ......
Leetcode108. 将有序数组转换为二叉搜索树
因为数组是有序的,可以递归的选取根节点构建子树。 JAVA: public final TreeNode sortedArrayToBST(int[] nums) { if (null == nums) return null; return this.build(nums, 0, nums.len ......
LeetCode #1131 Maximum of Absolute Value Expression 绝对值表达式的最大值
安装Flutter环境首先配置flutter3开发环境,照着官方教程傻瓜式安装即可。>>安装和环境配置 | Flutter 中文文档 | Flutter 中文开发者网站注意在国内网络环境下需要进行一些额外的环境配置:>>在中国网络环境下使用 Flutter | Flutter 中文文档 | Flut ......
Lucky Array
数据结构抽象题 法一:总共加 \(O(10^9)\) 次,我们常数超小的树状数组可以直接拿下!!!(时限4.0s) 法二:答案不多,值域不大,我们分块,块记录数出现的次数,然后用tag维护一下增量,注意cnt里的东西和tag没关系,查询才要用到tag。时间复杂度 \(O(30N\sqrt{N}=10 ......
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] 表示的高度图, ......