当前位置:网站首页>[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
边栏推荐
猜你喜欢
STM32中AHB总线_APB2总线_APB1总线这些是什么
SolidWorks工程图中添加中心线和中心符号线的办法
JMeter about setting thread group and time
0x0fa23729 (vcruntime140d.dll) (in classes and objects - encapsulation.Exe) exception thrown (resolved)
Serial communication relay Modbus communication host computer debugging software tool project development case
5个chrome简单实用的日常开发功能详解,赶快解锁让你提升更多效率!
LeetCode 练习——113. 路径总和 II
Adb 实用命令(网络包、日志、调优相关)
[sword finger offer] 42 Stack push in and pop-up sequence
Pdf document signature Guide
随机推荐
01 use function to approximate cosine function (15 points)
IO模型复习
php \n 换行无法输出
@Transcation的配置,使用,原理注意事项:
[email protected] can help us get the log object quickly
P1031 [NOIP2002 提高组] 均分纸牌
A small problem of bit field and symbol expansion
The story of Plato and his three disciples: how to find happiness? How to find the ideal partner?
Hdu-2196 tree DP learning notes
[ORM framework]
IDA中常见快捷键
宁愿把简单的问题说一百遍,也不把复杂的问题做一遍
C logging method
leetcode-560:和为 K 的子数组
Study summary of postgraduate entrance examination in October
JMeter loop controller and CSV data file settings are used together
【acwing】786. 第k个数
STM32 ADC and DMA
Multisim--软件相关使用技巧
浅谈日志中的返回格式封装格式处理,异常处理