当前位置:网站首页>Optimization is a kind of habit low starting point is the "standing near the critical"
Optimization is a kind of habit low starting point is the "standing near the critical"
2022-08-11 04:52:00 【a music】
1. Example: dynamic insertion and deletion of arrays
Consider the critical value
This critical value, not necessarily the last element

- Delete an element:

The first method: when the maximum value is obtained: i=size-1, the expression is: elements[size-2]=elements[size-1]
Second approach: When the maximum value is obtained: i=size-1, the expression is: elements[size-1]=elements[size] This is obviously not in line with the design. For example, the current array has size elements, thenThe last element should be elements[size-1]
In fact, crossing the boundary is also a thinking angle. If you stand at the covered angle, then the last covered element in the critical is the penultimate element of the current array elements[size-2]
The second approach: The loop judgment condition should be modified to be correct: for(int i = index; i < size-1; i++)
The first approach: is to stand at the cover angle, and also stand close to the 'threshold' (closer to the last element)The angle of font>, not easy to make mistakes, recommended
- Add an element:

In adding elements here: There is no problem with practice 1 and practice 2, but it is recommended,
Uniform Habits: The starting point is to "stand near critical"
边栏推荐
- 网络安全培训机构哪家好?排名怎么选择?
- Three 】 【 yolov7 series of actual combat from 0 to build training data sets
- 如何将360全景图导出高清短视频分享到视频平台上?
- 2021年网络规划设计师下午案例题
- 智能指针笔记
- Object Creation and Display Transformation
- Research on a Consensus Mechanism-Based Anti-Runaway Scheme for Digital Trunking Terminals
- 交换机和路由器技术-33-静态NAT
- 分层架构&SOA架构
- 洛谷P4560 Wall 砖墙
猜你喜欢

The principle, architecture, implementation, practice of "transfer" and "search", no need to be afraid of interviews

Overview of the JVM garbage collection and mechanism

【yolov7系列三】实战从0构建训练自己的数据集

「转」“搜索”的原理,架构,实现,实践,面试不用再怕了

应用层协议——DNS

交换机--- 生成树--三层架构总结

交换机和路由器技术-28-OSPF的NSSA区域

如何将360全景图导出高清短视频分享到视频平台上?
![[Likou] 22. Bracket generation](/img/f6/435fe9e0b4c1545514d1bf195ffd44.png)
[Likou] 22. Bracket generation

论文笔记:Bag of Tricks for Long-Tailed Visual Recognition with Deep Convolutional Neural Networks
随机推荐
洛谷P2580 于是他错误的点名开始了
无线电射频能量的收集
paddlepaddle实现CS_CE Loss且并入PaddleClas
洛谷P4560 Wall 砖墙
【yolov7系列三】实战从0构建训练自己的数据集
《卫星界》刊评“星辰大海”计划:孙宇晨为太空旅游带来新的机遇
Resize() usage row pit in vector
-填涂颜色-
2022新员工公司级安全教育基础培训(118页)
svg-icon的使用方法(svg-sprite-loader插件)
Add PRODUCT_BOOT_JARS and classes to provide jar packages to applications
MQ框架应用比较
JVM 垃圾回收的概述与机制
The basics of binary heap~
洛谷P4032 火锅盛宴
关于pom.xml文件
async(异步)和await的使用
zabbix构建企业级监控告警平台
FPGA工程师面试试题集锦121~130
leetcode 9. 回文数