当前位置:网站首页>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);
}
}
边栏推荐
- NAT地址转换
- [information security laws and regulations] review
- Learn open62541 -- [67] add custom enum and display name
- 初识缓存以及ehcache初体验「建议收藏」
- 反爬虫的重点:识别爬虫
- Flipping Game(枚举)
- [tpm2.0 principle and Application guide] Chapter 9, 10 and 11
- Kirk borne's selection of learning resources this week [click the title to download directly]
- 【塔望方法论】塔望3W消费战略 - U&A研究法
- 从39个kaggle竞赛中总结出来的图像分割的Tips和Tricks
猜你喜欢
标准ACL与扩展ACL
[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
单臂路由和三层交换的简单配置
gsap动画库
Will low code help enterprises' digital transformation make programmers unemployed?
Industry case | digital operation base helps the transformation of life insurance industry
The live broadcast reservation channel is open! Unlock the secret of fast launching of audio and video applications
Standard ACL and extended ACL
如何给“不卖笔”的晨光估值?
3. About cookies
随机推荐
2022.07.04
Redis
Three forms of multimedia technology commonly used in enterprise exhibition hall design
How many times is PTA 1101 B than a
Micro service remote debug, nocalhost + rainbow micro service development second bullet
Flipping Game(枚举)
静态路由配置
Static routing configuration
完整的电商系统
【剑指 Offer】59 - I. 滑动窗口的最大值
3. About cookies
Wechat web debugging 8.0.19 replace the X5 kernel with xweb, so the X5 debugging method can no longer be used. Now there is a solution
POJ 2392 Space Elevator
Rules for filling in volunteers for college entrance examination
博睿数据入选《2022爱分析 · IT运维厂商全景报告》
Standard ACL and extended ACL
数据验证框架 Apache BVal 再使用
Basic concepts and properties of binary tree
[mime notes]
2022上半年朋友圈都在传的10本书,找到了