当前位置:网站首页>[detailed explanation of Huawei machine test] tall and short people queue up
[detailed explanation of Huawei machine test] tall and short people queue up
2022-07-07 10:25:00 【A less intelligent programmer】
List of articles
Preface
《 Detailed explanation of Huawei's machine test questions Python Realization 》 The column includes Huawei column of niuke.com 、 Huawei test questions 、 Huawei OD Real problem of machine test .
If you are preparing for Huawei's interview , If you want to know something, you can send me a private letter , I will try my best to help you , I can also give you some suggestions !
This paper solves the non optimal solution ( Non optimal performance ).
Title Description
Now there is a group of children , They are different in height , We express the height of this group of children in an array of positive integers , Such as arrays {5,3,1,2,3}.
Now we want the children to line up , With “ high ”“ Short ”“ high ”“ Short ” Sequential arrangement , every last “ high ” The position of the children should be higher than the adjacent position or equal ; every last “ Short ” The children in the position should be shorter than or equal to the adjacent position ;
Ask the children to move at a minimum distance , The first one from “ high ” Start to line up , Output the minimum moving distance .
for example , In the demonstration team {5,3,1,2,3} in ,{5, 1, 3, 2, 3} It's the sorting result .{5, 2, 3, 1, 3} Although also satisfied “ high ”“ Short ”“ high ”“ Short ” Sequential arrangement , But children move a lot , So it's not the best result .
The definition of moving distance is as follows :
The second child moves behind the third child
边栏推荐
- [牛客网刷题 Day6] JZ27 二叉树的镜像
- Embedded background - chip
- Methods of adding centerlines and centerlines in SolidWorks drawings
- 搭建物联网硬件通信技术几种方案
- 2022.7.3DAY595
- Postman interface test VI
- HAL库配置通用定时器TIM触发ADC采样,然后DMA搬运到内存空间。
- Talking about the return format in the log, encapsulation format handling, exception handling
- 01 use function to approximate cosine function (15 points)
- Smart city construction based on GIS 3D visualization technology
猜你喜欢

【剑指Offer】42. 栈的压入、弹出序列

0x0fa23729 (vcruntime140d.dll) (in classes and objects - encapsulation.Exe) exception thrown (resolved)

IIC基本知识

Chris LATTNER, the father of llvm: why should we rebuild AI infrastructure software

嵌入式背景知识-芯片

【acwing】789. 数的范围(二分基础)

成为优秀的TS体操高手 之 TS 类型体操前置知识储备

字符串格式化

求方程ax^2+bx+c=0的根(C语言)

1324:【例6.6】整数区间
随机推荐
串口通讯继电器-modbus通信上位机调试软件工具项目开发案例
Postman interface test VII
【acwing】789. Range of numbers (binary basis)
When there are pointer variable members in the custom type, the return value and parameters of the assignment operator overload must be reference types
Several schemes of building hardware communication technology of Internet of things
Mongodb creates an implicit database as an exercise
[email protected]能帮助我们快速拿到日志对象
P1031 [NOIP2002 提高组] 均分纸牌
JMeter about setting thread group and time
Postman interface test II
Postman interface test VI
【acwing】786. 第k个数
【HigherHRNet】 HigherHRNet 详解之 HigherHRNet的热图回归代码
0x0fa23729 (vcruntime140d.dll) (in classes and objects - encapsulation.Exe) exception thrown (resolved)
Slurm资源管理与作业调度系统安装配置
【剑指Offer】42. 栈的压入、弹出序列
Embedded background - chip
浅谈日志中的返回格式封装格式处理,异常处理
2022.7.4DAY596
Vs code specifies the extension installation location