当前位置:网站首页>LeetCode1051(C#)
LeetCode1051(C#)
2022-07-07 19:13:00 【Just be interesting】
subject
The school plans to take an annual commemorative photo for all the students . According to the requirements , Students need to follow The decreasing Line up in order of height .
The sorted height is an integer array expected Express , among expected[i] It's expected to be number... In this line i The height of a student ( Subscript from 0 Start ).
Give you an array of integers heights , Express Current student position The height of .heights[i] It's the... In this line i The height of a student ( Subscript from 0 Start ).
Return to satisfaction heights[i] != expected[i] Of Subscript quantity .
Example 1:
Input :heights = [1,1,4,2,1,3]
Output :3
explain :
Height :[1,1,4,2,1,3]
expect :[1,1,1,2,3,4]
Subscript 2 、4 、5 The height of the students at does not match .
Example 2:
Input :heights = [5,1,2,3,4]
Output :5
explain :
Height :[5,1,2,3,4]
expect :[1,2,3,4,5]
The corresponding student heights of all subscripts do not match .
Example 3:
Input :heights = [1,2,3,4,5]
Output :0
explain :
Height :[1,2,3,4,5]
expect :[1,2,3,4,5]
The corresponding student heights of all subscripts match .
Code
- Linq One sentence sweeping the world
public class Solution
{
public int HeightChecker(int[] heights)
{
return heights.OrderBy(h => h).
Zip(heights, (e,h) => (first : e, second : h)).
Count(eh => eh.first != eh.second);
}
}
边栏推荐
- Rules for filling in volunteers for college entrance examination
- Cadre de validation des données Apache bval réutilisé
- 2022上半年朋友圈都在传的10本书,找到了
- 企业MES制造执行系统的分类与应用
- POJ 2392 Space Elevator
- Tsinghua, Cambridge and UIC jointly launched the first Chinese fact verification data set: evidence-based, covering many fields such as medical society
- 2022.07.02
- Differences between rip and OSPF and configuration commands
- PTA 1102 teaching Super Champion volume
- Thread factory in thread pool
猜你喜欢

Redis cluster and expansion

Policy mode - unity
![[tpm2.0 principle and Application guide] Chapter 16, 17 and 18](/img/7a/b16549590e6445d9199c8000d47d36.png)
[tpm2.0 principle and Application guide] Chapter 16, 17 and 18

企业展厅设计中常用的三种多媒体技术形式

Multimodal point cloud fusion and visual location based on image and laser

Calculation of torque target value (ftorque) in servo torque control mode

Realize payment function in applet

Will low code help enterprises' digital transformation make programmers unemployed?
![[Blue Bridge Cup training 100 questions] sort scratch from small to large. Blue Bridge Cup scratch competition special prediction programming question centralized training simulation exercise question](/img/08/5f4b4e2700606554516807c01454fd.png)
[Blue Bridge Cup training 100 questions] sort scratch from small to large. Blue Bridge Cup scratch competition special prediction programming question centralized training simulation exercise question

多个kubernetes集群如何实现共享同一个存储
随机推荐
脑洞从何而来?加州大学最新研究:有创造力的人神经连接会「抄近道」
[Base64 notes] [suggestions collection]
AI写首诗
In 2021, the national average salary was released. Have you reached the standard?
Realize payment function in applet
Initial experience of cache and ehcache "suggestions collection"
抢占周杰伦
IP netns command (memo)
数据验证框架 Apache BVal 再使用
AI来搞财富分配比人更公平?来自DeepMind的多人博弈游戏研究
【Base64笔记】「建议收藏」
Cadre de validation des données Apache bval réutilisé
The live broadcast reservation channel is open! Unlock the secret of fast launching of audio and video applications
A hodgepodge of ICER knowledge points (attached with a large number of topics, which are constantly being updated)
Hongmeng smart home [1.0]
UVALive – 4621 Cav 贪心 + 分析「建议收藏」
2022.07.04
虚拟数字人里的生意经
Policy mode - unity
将模型的记忆保存下来!Meta&UC Berkeley提出MeMViT,建模时间支持比现有模型长30倍,计算量仅增加4.5%...