当前位置:网站首页>[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
边栏推荐
猜你喜欢
Postman interface test V
【剑指Offer】42. 栈的压入、弹出序列
【HigherHRNet】 HigherHRNet 详解之 HigherHRNet的热图回归代码
P2788 数学1(math1)- 加减算式
[higherhrnet] higherhrnet detailed heat map regression code of higherhrnet
Vs code specifies the extension installation location
Chris Lattner, père de llvm: Pourquoi reconstruire le logiciel d'infrastructure ai
ISP、IAP、ICP、JTAG、SWD的编程特点
1321:【例6.3】删数问题(Noip1994)
Programming features of ISP, IAP, ICP, JTAG and SWD
随机推荐
ORM -- database addition, deletion, modification and query operation logic
Can I open a stock trading account online? Is it safe
ORM -- query type, association query
Postman interface test VII
IDA中常见快捷键
This article explains the complex relationship between MCU, arm, muc, DSP, FPGA and embedded system
STM32 ADC and DMA
求方程ax^2+bx+c=0的根(C语言)
嵌入式工程师如何提高工作效率
OpenGL glLightfv 函数的应用以及光源的相关知识
Study summary of postgraduate entrance examination in October
ISP、IAP、ICP、JTAG、SWD的编程特点
@Configuration, use, principle and precautions of transmission:
深入分析ERC-4907协议的主要内容,思考此协议对NFT市场流动性意义!
IIC基本知识
IO模型复习
Guid primary key
ArcGIS operation: batch modify attribute table
P2788 数学1(math1)- 加减算式
. Net configuration system