当前位置:网站首页>LeetCode学习记录(从新手村出发之杀不出新手村)----1
LeetCode学习记录(从新手村出发之杀不出新手村)----1
2022-07-06 13:38:00 【励志拿高薪】
数组总览
集合:简单来说,可以说是一个或多个元素构成的整体。构成集合的元素的类型可以是不同的,同时这些元素也是无序的。
列表:是一种线性表。它是由元素按照一定顺序排列在一起,是有序的。列表常见的表现形式有:数组、链表、堆、栈。
数组:数组引入了索引的概念,可以通过下标来查找对应元素的位置。同时,由于有下标,证明数组存储的数据是连续的。不同于数组,链表是不连续的。
数组的读取:根据数组下标即可找到对应的元素,只操作一个数据,因此时间复杂度为O(1)。
数组的查找:按照最坏的情况考虑,如果要查找的数据在最尾部,那么需要从数组的0位置索引一直到数组的最后一个索引。那么时间复杂度为O(N)。
数组的插入:如果要将该元素插入到数组的末尾,只需要一步。即计算机通过数组的长度和位置计算出即将插入元素的内存地址,然后将该元素插入到指定位置即可。然而,如果要将该元素插入到数组中的其他位置,则会有所区别,这时我们首先需要为该元素所要插入的位置腾出空间,然后进行插入操作。
数组的删除:删除元素与插入元素的操作类似,当我们删除掉数组中的某个元素后,数组中会留下 空缺 的位置,而数组中的元素在内存中是连续的,这就使得后面的元素需对该位置进行填补操作。
例题1:力扣https://leetcode-cn.com/problems/find-the-middle-index-in-array/
刚刚起步还只会遍历(感觉要在新手村出不去了)
边栏推荐
- 【力扣刷题】一维动态规划记录(53零钱兑换、300最长递增子序列、53最大子数组和)
- 启动嵌入式间:资源有限的系统启动
- mysql根据两个字段去重
- 华为在多个行业同时出击,吓人的技术让欧美企业瑟瑟发抖
- The role of applicationmaster in spark on Yan's cluster mode
- Reset Mikrotik Routeros using netinstall
- The underlying implementation of string
- [Li Kou brushing questions] one dimensional dynamic planning record (53 change exchanges, 300 longest increasing subsequence, 53 largest subarray and)
- MPLS experiment
- R3live notes: image processing section
猜你喜欢
Happy sound 2[sing.2]
The golden age of the U.S. technology industry has ended, and there have been constant lamentations about chip sales and 30000 layoffs
Four common ways and performance comparison of ArrayList de duplication (jmh performance analysis)
JS method to stop foreach
Why does MySQL index fail? When do I use indexes?
Yuan Xiaolin: safety is not only a standard, but also Volvo's unchanging belief and pursuit
1292_ Implementation analysis of vtask resume() and xtask resume fromisr() in freeros
Numpy download and installation
Enhance network security of kubernetes with cilium
Caching strategies overview
随机推荐
Tiktok will push the independent grass planting app "praiseworthy". Can't bytes forget the little red book?
美国科技行业结束黄金时代,芯片求售、裁员3万等哀声不断
Univariate cubic equation - relationship between root and coefficient
Tips for web development: skillfully use ThreadLocal to avoid layer by layer value transmission
技术分享 | 抓包分析 TCP 协议
WEB功能测试说明
R language for text mining Part4 text classification
在最长的距离二叉树结点
Five wars of Chinese Baijiu
Huawei has launched attacks in many industries at the same time, and its frightening technology has made European and American enterprises tremble
guava:Collections. The collection created by unmodifiablexxx is not immutable
首批入选!腾讯安全天御风控获信通院业务安全能力认证
Yuan Xiaolin: safety is not only a standard, but also Volvo's unchanging belief and pursuit
Numpy download and installation
FZU 1686 龙之谜 重复覆盖
The underlying implementation of string
High precision face recognition based on insightface, which can directly benchmark hongruan
PostgreSQL 修改数据库用户的密码
对话阿里巴巴副总裁贾扬清:追求大模型,并不是一件坏事
MPLS experiment