当前位置:网站首页>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"
边栏推荐
- 我的LaTeX入门
- 延长经济保险(jeecgboot)
- Embedded Sharing Collection 33
- To break the bottleneck of transactional work, the gentleman signs the electronic contract to release the "source power" of HR!
- 如何阅读论文
- 交换机和路由器技术-32-命名ACL
- 论文笔记:Bag of Tricks for Long-Tailed Visual Recognition with Deep Convolutional Neural Networks
- 交换机和路由器技术-28-OSPF的NSSA区域
- 交换机和路由器技术-35-NAT转PAT
- 网络安全培训机构哪家好?排名怎么选择?
猜你喜欢
论文笔记:Bag of Tricks for Long-Tailed Visual Recognition with Deep Convolutional Neural Networks
zabbix构建企业级监控告警平台
svg-icon的使用方法(svg-sprite-loader插件)
简历里写了会代码,却依然过不了面试这一关
ALSA音频架构
Embedded Sharing Collection 33
ERROR: Could not install packages due to an OSError: [Errno 2] 没有那个文件或目录: ‘/data/xxxx
《卫星界》刊评“星辰大海”计划:孙宇晨为太空旅游带来新的机遇
CAN/以太网转换器 CAN与以太网互联互通
交换机和路由器技术-31-扩展ACL
随机推荐
关于pom.xml文件
To break the bottleneck of transactional work, the gentleman signs the electronic contract to release the "source power" of HR!
Resize() usage row pit in vector
应用层协议——DNS
交换机和路由器技术-30-标准ACL
redis按照正则批量删除key
交换机和路由器技术-29-OSPF虚链路
我的LaTeX入门
交换机和路由器技术-31-扩展ACL
Application of Identification Cryptography in IMS Network
How to add icons to web pages?
form表单提交数据库中文变成问号
-填涂颜色-
JVM 垃圾回收的概述与机制
findViewById返回null的问题
交换机和路由器技术-28-OSPF的NSSA区域
延长经济保险(jeecgboot)
Use Navicat Premium to export database table structure information to Excel
svg-icon的使用方法(svg-sprite-loader插件)
【yolov7系列三】实战从0构建训练自己的数据集