当前位置:网站首页>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/
刚刚起步还只会遍历(感觉要在新手村出不去了)
边栏推荐
- 技术分享 | 抓包分析 TCP 协议
- JPEG2000-Matlab源码实现
- Depth first traversal (DFS) and breadth first traversal (BFS)
- 华为在多个行业同时出击,吓人的技术让欧美企业瑟瑟发抖
- Sql: stored procedures and triggers - Notes
- NPM run dev start project error document is not defined
- One line by line explanation of the source code of anchor free series network yolox (a total of ten articles, you can change the network at will after reading it, if you won't complain to me)
- 互联网快讯:吉利正式收购魅族;胰岛素集采在31省全面落地
- Fastjson parses JSON strings (deserialized to list, map)
- Start the embedded room: system startup with limited resources
猜你喜欢
numpy 下载安装
Persistence / caching of RDD in spark
[in depth learning] pytorch 1.12 was released, officially supporting Apple M1 chip GPU acceleration and repairing many bugs
[Li Kou brush questions] 32 Longest valid bracket
Shake Sound poussera l'application indépendante de plantation d'herbe "louable", les octets ne peuvent pas oublier le petit livre rouge?
50个常用的Numpy函数解释,参数和使用示例
Internet News: Geely officially acquired Meizu; Intensive insulin purchase was fully implemented in 31 provinces
美国科技行业结束黄金时代,芯片求售、裁员3万等哀声不断
Four common ways and performance comparison of ArrayList de duplication (jmh performance analysis)
guava:Collections. The collection created by unmodifiablexxx is not immutable
随机推荐
Broadcast variables and accumulators in spark
JS get array subscript through array content
Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic
c语言char, wchar_t, char16_t, char32_t和字符集的关系
Redistemplate common collection instructions opsforset (V)
Sdl2 source analysis 7: performance (sdl_renderpresent())
50 commonly used numpy function explanations, parameters and usage examples
Record the process of cleaning up mining viruses
Checkpoint of RDD in spark
The golden age of the U.S. technology industry has ended, and there have been constant lamentations about chip sales and 30000 layoffs
It's not my boast. You haven't used this fairy idea plug-in!
ROS error: could not find a package configuration file provided by "move_base“
1D convolution detail
Microsoft technology empowerment position - February course Preview
Why rdd/dataset is needed in spark
SDL2来源分析7:演出(SDL_RenderPresent())
The relationship between root and coefficient of quadratic equation with one variable
Huawei has launched attacks in many industries at the same time, and its frightening technology has made European and American enterprises tremble
PostgreSQL 安装gis插件 CREATE EXTENSION postgis_topology
The underlying implementation of string