当前位置:网站首页>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/
刚刚起步还只会遍历(感觉要在新手村出不去了)

边栏推荐
- 分糖果
- 通过数字电视通过宽带网络取代互联网电视机顶盒应用
- C how to set two columns comboboxcolumn in DataGridView to bind a secondary linkage effect of cascading events
- Efficiency tool +wps check box shows the solution to the sun problem
- Depth first traversal (DFS) and breadth first traversal (BFS)
- PostgreSQL modifies the password of the database user
- guava:创建immutableXxx对象的3种方式
- Tiktok will push the independent grass planting app "praiseworthy". Can't bytes forget the little red book?
- Vit paper details
- guava:Collections.unmodifiableXXX创建的collection并不immutable
猜你喜欢

【力扣刷题】32. 最长有效括号

Sequoia China, just raised $9billion

Vit paper details

Basic introduction of figure

Efficiency tool +wps check box shows the solution to the sun problem
![[redis design and implementation] part I: summary of redis data structure and objects](/img/2e/b147aa1e23757519a5d049c88113fe.png)
[redis design and implementation] part I: summary of redis data structure and objects

Caching strategies overview

快讯:飞书玩家大会线上举行;微信支付推出“教培服务工具箱”
![关于char[]数组通过scanf赋值使用上的一些问题。。](/img/cf/d85a3172c5d29ac00377f9c30dbc4f.png)
关于char[]数组通过scanf赋值使用上的一些问题。。

抖音将推独立种草App“可颂”,字节忘不掉小红书?
随机推荐
[Digital IC manual tearing code] Verilog automatic beverage machine | topic | principle | design | simulation
跨分片方案 总结
What can one line of code do?
语谱图怎么看
Why is the cluster mode of spark on Yan better than the client mode
Huawei has launched attacks in many industries at the same time, and its frightening technology has made European and American enterprises tremble
Persistence / caching of RDD in spark
Acdreamoj1110 (multiple backpacks)
JS method to stop foreach
NPM run dev start project error document is not defined
Set up a time server
Basic introduction of figure
[Li Kou brush questions] 32 Longest valid bracket
Guava: three ways to create immutablexxx objects
JPEG2000-Matlab源码实现
缓存更新策略概览(Caching Strategies Overview)
Four common ways and performance comparison of ArrayList de duplication (jmh performance analysis)
guava: Multiset的使用
The use method of string is startwith () - start with XX, endswith () - end with XX, trim () - delete spaces at both ends
强化学习-学习笔记5 | AlphaGo