当前位置:网站首页>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);
}
}
边栏推荐
- 二叉树的基本概念和性质
- 【MIME笔记】
- LeetCode 890(C#)
- Three forms of multimedia technology commonly used in enterprise exhibition hall design
- 我感觉被骗了,微信内测 “大小号” 功能,同一手机号可注册两个微信
- Recommend free online SMS receiving platform in 2022 (domestic and foreign)
- 直播预约通道开启!解锁音视频应用快速上线的秘诀
- cmd命令进入MySQL时报服务名或者命令错误(傻瓜式教学)
- 标准ACL与扩展ACL
- How much does it cost to develop a small program mall?
猜你喜欢

RISCV64

直播预约通道开启!解锁音视频应用快速上线的秘诀
![[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

Tsinghua, Cambridge and UIC jointly launched the first Chinese fact verification data set: evidence-based, covering many fields such as medical society

Cadre de validation des données Apache bval réutilisé

Reinforcement learning - learning notes 8 | Q-learning

RIP和OSPF的区别和配置命令

Static routing configuration

Basic operation of chain binary tree (implemented in C language)

SlashData开发者工具榜首等你而定!!!
随机推荐
微信网页调试8.0.19换掉X5内核,改用xweb,所以x5调试方式已经不能用了,现在有了解决方案
Is AI more fair than people in the distribution of wealth? Research on multiplayer game from deepmind
RISCV64
Calculation of torque target value (ftorque) in servo torque control mode
10 schemes to ensure interface data security
CVPR 2022 - learning non target knowledge for semantic segmentation of small samples
二叉树的基本概念和性质
The top of slashdata developer tool is up to you!!!
Three forms of multimedia technology commonly used in enterprise exhibition hall design
Save the memory of the model! Meta & UC Berkeley proposed memvit. The modeling time support is 30 times longer than the existing model, and the calculation amount is only increased by 4.5%
2022上半年朋友圈都在传的10本书,找到了
【软件测试】从企业版BOSS直聘,看求职简历,你没被面上是有原因的
Kirk borne's selection of learning resources this week [click the title to download directly]
Hongmeng smart home [1.0]
Initial experience of cache and ehcache "suggestions collection"
Comparison and selection of kubernetes Devops CD Tools
Creative changes brought about by the yuan universe
ip netns 命令(备忘)
Desci: is decentralized science the new trend of Web3.0?
[software test] from the direct employment of the boss of the enterprise version, looking at the resume, there is a reason why you are not covered