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

边栏推荐
- Basic introduction of figure
- 通过数字电视通过宽带网络取代互联网电视机顶盒应用
- 用aardio写一个旋转验证码标注小工具
- The underlying implementation of string
- uni-app App端半屏连续扫码
- PostgreSQL 安装gis插件 CREATE EXTENSION postgis_topology
- 袁小林:安全不只是标准,更是沃尔沃不变的信仰和追求
- Leveldb source code analysis series - main process
- Redistemplate common collection instructions opsforlist (III)
- 20 large visual screens that are highly praised by the boss, with source code templates!
猜你喜欢

Aggregate function with key in spark

ViT论文详解
![[Digital IC manual tearing code] Verilog automatic beverage machine | topic | principle | design | simulation](/img/75/c0656c4890795bd65874b4f2b16462.jpg)
[Digital IC manual tearing code] Verilog automatic beverage machine | topic | principle | design | simulation
![[Chongqing Guangdong education] Information Literacy of Sichuan Normal University: a new engine for efficiency improvement and lifelong learning reference materials](/img/a5/94bdea3a871db5305ef54e3b304beb.jpg)
[Chongqing Guangdong education] Information Literacy of Sichuan Normal University: a new engine for efficiency improvement and lifelong learning reference materials

Tiktok will push the independent grass planting app "praiseworthy". Can't bytes forget the little red book?

Persistence / caching of RDD in spark

bat脚本学习(一)

Internet News: Geely officially acquired Meizu; Intensive insulin purchase was fully implemented in 31 provinces

Caching strategies overview

Numpy download and installation
随机推荐
Start the embedded room: system startup with limited resources
c语言char, wchar_t, char16_t, char32_t和字符集的关系
JS traversal array and string
[Chongqing Guangdong education] Tianjin urban construction university concrete structure design principle a reference
Guava: three ways to create immutablexxx objects
PostgreSQL modifies the password of the database user
一行代码可以做些什么?
Redistemplate common collection instructions opsforlist (III)
Replace Internet TV set-top box application through digital TV and broadband network
guava:Collections.unmodifiableXXX创建的collection并不immutable
Redistemplate common collection instructions opsforzset (VI)
b站视频链接快速获取
The underlying implementation of string
Binary tree node at the longest distance
强化学习-学习笔记5 | AlphaGo
语谱图怎么看
Set up a time server
Reptile practice (V): climbing watercress top250
string的底层实现
mysql根据两个字段去重