当前位置:网站首页>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);
}
}
边栏推荐
- Scientists have observed for the first time that the "electron vortex" helps to design more efficient electronic products
- 能同时做三个分割任务的模型,性能和效率优于MaskFormer!Meta&UIUC提出通用分割模型,性能优于任务特定模型!开源!...
- 【塔望方法论】塔望3W消费战略 - U&A研究法
- Interview vipshop internship testing post, Tiktok internship testing post [true submission]
- In 2021, the national average salary was released. Have you reached the standard?
- POJ 1182 :食物链(并查集)[通俗易懂]
- [Tawang methodology] Tawang 3W consumption strategy - U & a research method
- 2022年推荐免费在线接收短信平台(国内、国外)
- AI写首诗
- Flipping game (enumeration)
猜你喜欢
Do you know all four common cache modes?
Policy mode - unity
Static routing configuration
Pasqal首席技术官:模拟量子计算率先为工业带来量子优势
微服务远程Debug,Nocalhost + Rainbond微服务开发第二弹
Charles+Postern的APP抓包
抢占周杰伦
Multimodal point cloud fusion and visual location based on image and laser
99% of people don't know that privatized deployment is also a permanently free instant messaging software!
虚拟数字人里的生意经
随机推荐
POJ 2392 Space Elevator
我感觉被骗了,微信内测 “大小号” 功能,同一手机号可注册两个微信
Antisamy: a solution against XSS attack tutorial
[Base64 notes] [suggestions collection]
How much does it cost to develop a small program mall?
SD_ DATA_ RECEIVE_ SHIFT_ REGISTER
初识缓存以及ehcache初体验「建议收藏」
[tpm2.0 principle and Application guide] Chapter 16, 17 and 18
将模型的记忆保存下来!Meta&UC Berkeley提出MeMViT,建模时间支持比现有模型长30倍,计算量仅增加4.5%...
数据验证框架 Apache BVal 再使用
Calculation of torque target value (ftorque) in servo torque control mode
Will domestic software testing be biased
Interview vipshop internship testing post, Tiktok internship testing post [true submission]
抢占周杰伦
In 2021, the national average salary was released. Have you reached the standard?
Nat address translation
二叉树的基本概念和性质
虚拟数字人里的生意经
Recommend free online SMS receiving platform in 2022 (domestic and foreign)
2022.07.02