当前位置:网站首页>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);
}
}
边栏推荐
- Policy mode - unity
- [tpm2.0 principle and Application guide] Chapter 16, 17 and 18
- Comparison and selection of kubernetes Devops CD Tools
- Realize payment function in applet
- 咋吃都不胖的朋友,Nature告诉你原因:是基因突变了
- 微信网页调试8.0.19换掉X5内核,改用xweb,所以x5调试方式已经不能用了,现在有了解决方案
- Pasqal首席技术官:模拟量子计算率先为工业带来量子优势
- 将模型的记忆保存下来!Meta&UC Berkeley提出MeMViT,建模时间支持比现有模型长30倍,计算量仅增加4.5%...
- 线程池中的线程工厂
- App capture of charles+drony
猜你喜欢
DeSci:去中心化科学是Web3.0的新趋势?
Short selling, overprinting and stock keeping, Oriental selection actually sold 2.66 million books in Tiktok in one month
Three forms of multimedia technology commonly used in enterprise exhibition hall design
基于图像和激光的多模态点云融合与视觉定位
Review of network attack and defense
50亿,福建又诞生一只母基金
Redis cluster and expansion
虚拟数字人里的生意经
前首富,沉迷种田
Do you know all four common cache modes?
随机推荐
[tpm2.0 principle and Application guide] Chapter 9, 10 and 11
[Tawang methodology] Tawang 3W consumption strategy - U & a research method
POJ 2392 Space Elevator
Flipping game (enumeration)
直播预约通道开启!解锁音视频应用快速上线的秘诀
How much does it cost to develop a small program mall?
标准ACL与扩展ACL
Review of network attack and defense
Redis
Creative changes brought about by the yuan universe
Golang client server login
2022上半年朋友圈都在传的10本书,找到了
虚拟数字人里的生意经
来了!GaussDB(for Cassandra)新特性亮相
[HDU] 5248 sequence transformation (greedy + dichotomy) [recommended collection]
Flipping Game(枚举)
如何给“不卖笔”的晨光估值?
"Decryption" Huawei machine vision Corps: Huawei is moving up and the industry is moving forward
unity2d的Rigidbody2D的MovePosition函数移动时人物或屏幕抖动问题解决
Nat address translation