数组
文章平均质量分 79
各种语言实现数组(动态)的;涉及到数组的OJ题目等
memcpy0
希望探索文理结合的自由之路。
展开
-
LeetCode 2391. 收集垃圾的最少总时间【倒序遍历+贡献法】1455
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2024-05-12 15:49:20 · 874 阅读 · 0 评论 -
LeetCode 2079. 给植物浇水【数组】1320
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2024-05-09 01:24:28 · 281 阅读 · 0 评论 -
LeetCode 1652. 拆炸弹【定长滑窗】简单
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2024-05-05 16:14:55 · 1034 阅读 · 0 评论 -
LeetCode 2639. 查询网格图中每一列的宽度【数组】简单
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2024-04-27 16:45:40 · 650 阅读 · 0 评论 -
LeetCode 2125. 银行中的激光束数量【数组,遍历】1280
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2024-01-06 00:02:25 · 596 阅读 · 0 评论 -
LeetCode 1582. 二进制矩阵中的特殊位置【数组,列的特殊值】1321
给你一个大小为 rows x cols 的矩阵 mat ,其中 mat[i][j] 是 0 或 1 ,请返回 矩阵 mat 中特殊位置的数目 。特殊位置 定义:如果 mat[i][j] == 1 并且第 i 行和第 j 列中的所有其他元素均为 0(行和列的下标均 从 0 开始 ),则位置 (i, j) 被称为特殊位置。示例 1:输入:mat = [[1,0,0], [0,0,1], [1,0,0]]输出:1解释:(1,2) 是一个特殊位置,因为 ma原创 2020-09-17 19:32:37 · 159 阅读 · 0 评论 -
LeetCode 2706. 购买两块巧克力【数组,一次遍历】1207
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2024-01-01 17:42:30 · 1018 阅读 · 0 评论 -
LeetCode 2735. 收集巧克力【枚举】2043
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-12-29 01:43:44 · 932 阅读 · 0 评论 -
LeetCode 2678. 老人的数目【数组】简单
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-10-23 00:37:09 · 228 阅读 · 0 评论 -
LeetCode 414. Third Maximum Number【数组】简单
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。为了方便在PC上运行调试、分享代码文件,我还建立了相关的。原创 2023-10-22 15:07:38 · 245 阅读 · 0 评论 -
LeetCode 799. 香槟塔【数组,模拟,简单线性DP】1855
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-10-20 01:23:18 · 306 阅读 · 0 评论 -
LeetCode 2906. 构造乘积矩阵【前后缀分解,数组】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-10-16 11:30:14 · 487 阅读 · 0 评论 -
LeetCode 59. 螺旋矩阵 II【数组,模拟】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-10-09 20:23:32 · 79 阅读 · 0 评论 -
LeetCode 1222. 可以攻击国王的皇后【数组,模拟】1391
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-09-15 13:10:57 · 105 阅读 · 0 评论 -
LeetCode 2596. 检查骑士巡视方案【数组,模拟】1448
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。为了方便在PC上运行调试、分享代码文件,我还建立了相关的。原创 2023-09-13 10:49:32 · 138 阅读 · 0 评论 -
LeetCode 2090. K Radius Subarray Averages【前缀和,滑动窗口,数组】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-06-21 23:11:53 · 534 阅读 · 0 评论 -
LeetCode 1253. Reconstruct a 2-Row Binary Matrix【贪心,数组】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-06-18 23:33:08 · 1640 阅读 · 0 评论 -
LeetCode 892. Surface Area of 3D Shapes【数组,数学】简单
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-06-17 12:22:59 · 1466 阅读 · 0 评论 -
LeetCode 1330. Reverse Subarray To Maximize Array Value【分类讨论,数学,数组】困难
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-05-13 23:33:55 · 348 阅读 · 0 评论 -
LeetCode 2488. Count Subarrays With Median K【哈希表,数学,数组】困难
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-03-21 21:07:27 · 337 阅读 · 0 评论 -
LeetCode 2373. Largest Local Values in a Matrix【数组,最大池化】
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。为了方便在PC上运行调试、分享代码文件,我还建立了相关的。原创 2023-03-01 04:16:49 · 169 阅读 · 0 评论 -
LeetCode 2210. Count Hills and Valleys in an Array【数组/哨兵】简单
You are given a 0-indexed integer array nums. An index i is part of a hill in nums if the closest non-equal neighbors of i are smaller than nums[i]. Similarly, an index i is part of a valley in nums if the closest non-equal neighbors of i are larger than n原创 2022-03-22 01:13:51 · 585 阅读 · 0 评论 -
LeetCode 414. Third Maximum Number【数组】简单
414. Third Maximum Number 【easy】Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n...原创 2020-02-13 13:44:51 · 287 阅读 · 0 评论 -
LeetCode 284. Peeking Iterator【设计/迭代器/数组】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。为了方便在PC上运行调试、分享代码文件,我还建立了相关的仓库。在这一仓库中,你不仅可以看到LeetCode原题链接、题解代码、题解文章链接、同类.原创 2021-11-11 16:48:50 · 231 阅读 · 1 评论 -
LeetCode 162. Find Peak Element【数组/二分】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。为了方便在PC上运行调试、分享代码文件,我还建立了相关的仓库:https://github.com/memcpy0/LeetCode-Conqu.原创 2021-10-16 01:41:47 · 136 阅读 · 0 评论 -
LeetCode 剑指 Offer II 069. 山峰数组的顶部【二分/三分/数组】简单
符合下列属性的数组 arr 称为 山峰数组(山脉数组) : arr.length >= 3 存在 i(0 < i < arr.length - 1)使得: arr[0] < arr[1] < ... arr[i-1] < arr[i] arr[i] > arr[i+1] > ... > arr[arr.length - 1] 给定由整数组成的山峰数组 arr ,返回任何满足 arr[0] < arr[1] < .原创 2021-10-15 23:13:18 · 158 阅读 · 0 评论 -
LeetCode 2016. Maximum Difference Between Increasing Elements【数组】简单
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。为了方便在PC上运行调试、分享代码文件,我还建立了相关的仓库:https://github.com/memcpy0/LeetCode-Conqu.原创 2021-09-30 17:24:38 · 145 阅读 · 0 评论 -
LeetCode 2012. Sum of Beauty in the Array【数组/递推】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。为了方便在PC上运行调试、分享代码文件,我还建立了相关的仓库:https://github.com/memcpy0/LeetCode-Conqu.原创 2021-09-25 21:41:27 · 204 阅读 · 0 评论 -
LeetCode 2006. Count Number of Pairs With Absolute Difference K【数组/哈希表】简单
Given an integer array nums and an integer k, return the number of pairs (i, j) where i < j such that |nums[i] - nums[j]| == k.The value of |x| is defined as: x if x >= 0. -x if x < 0.Example 1:Input: nums = [1,2,2,1], k = 1Output: 4Expla原创 2021-09-25 19:26:03 · 190 阅读 · 0 评论 -
LeetCode 275. H-Index II【数组,二分】中等
Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper and citations is sorted in an ascending order, return compute the researcher's h-index.According to the definition of h-index原创 2021-07-12 23:48:32 · 142 阅读 · 1 评论 -
LeetCode 1893. Check if All the Integers in a Range Are Covered【数组/差分】简单
You are given a 2D integer array ranges and two integers left and right. Each ranges[i] = [starti, endi] represents an inclusive interval between starti and endi.Return true if each integer in the inclusive range [left, right] is covered by at least one i原创 2021-06-15 22:30:29 · 262 阅读 · 1 评论 -
LeetCode 969. Pancake Sorting【排序/数组】中等
Given an array of integers arr, sort the array by performing a series of pancake flips.In one pancake flip we do the following steps: Choose an integer k where 1 <= k <= arr.length. Reverse the sub-array arr[0...k-1] (0-indexed).For example, if原创 2021-06-07 01:01:17 · 163 阅读 · 0 评论 -
LeetCode C++ 1267. Count Servers that Communicate【Array】中等
You are given a map of a server center, represented as a m * n integer matrix grid, where 1 means that on that cell there is a server and 0 means that it is no server. Two servers are said to communicate if they are on the same row or on the same colu原创 2021-05-17 21:31:56 · 155 阅读 · 0 评论 -
LeetCode C++ 1854. Maximum Population Year【Array/Difference】简单
You are given a 2D integer array logs where each logs[i] = [birthi, deathi] indicates the birth and death years of the ith person.The population of some year x is the number of people alive during that year. The ith person is counted in year x's populatio原创 2021-05-13 21:46:55 · 193 阅读 · 1 评论 -
LeetCode C++ 1725. Number Of Rectangles That Can Form The Largest Square【Array】简单
You are given an array rectangles where rectangles[i] = [li, wi] represents the ith rectangle of length li and width wi.You can cut the ith rectangle to form a square with a side length of k if both k <= li and k <= wi. For example, if you have a re原创 2021-05-04 02:00:22 · 335 阅读 · 0 评论 -
LeetCode C++ 1742. Maximum Number of Balls in a Box【Array】简单
You are working in a ball factory where you have n balls numbered from lowLimit up to highLimit inclusive (i.e., n == highLimit - lowLimit + 1), and an infinite number of boxes numbered from 1 to infinity.Your job at this factory is to put each ball in th原创 2021-05-04 01:55:19 · 205 阅读 · 0 评论 -
LeetCode C++ 1848. Minimum Distance to the Target Element【Array】简单
Given an integer array nums (0-indexed) and two integers target and start, find an index i such that nums[i] == target and abs(i - start) is minimized. Note that abs(x) is the absolute value of x.Return abs(i - start).It is guaranteed that targ原创 2021-05-04 01:32:08 · 145 阅读 · 0 评论 -
LeetCode C++ 1732. Find the Highest Altitude【Array/前缀和】简单
There is a biker going on a road trip. The road trip consists of n + 1 points at different altitudes. The biker starts his trip on point 0 with altitude equal 0.You are given an integer array gain of length n where gain[i] is the net gain in altitude betw原创 2021-05-04 01:18:57 · 143 阅读 · 0 评论 -
LeetCode C++ 1773. Count Items Matching a Rule【Array/String】简单
You are given an array items, where each items[i] = [typei, colori, namei] describes the type, color, and name of the ith item. You are also given a rule represented by two strings, ruleKey and ruleValue.The ith item is said to match the rule if one of th原创 2021-05-01 16:37:27 · 167 阅读 · 0 评论 -
LeetCode C++ 1779. Find Nearest Point That Has the Same X or Y Coordinate【Array】简单
You are given two integers, x and y, which represent your current location on a Cartesian grid: (x, y). You are also given an array points where each points[i] = [ai, bi] represents that a point exists at (ai, bi). A point is valid if it shares the same x-原创 2021-05-01 15:11:18 · 253 阅读 · 0 评论