手机壁纸网站大全,企业网站建设的一般要素,简单网页素材,建网站是什么技术文章目录1. 题目2. 解题1. 题目
描述 班上的学生根据他们的年级照片的身高升序排列#xff0c;确定当前未站在正确位置的学生人数
数组长度 10^5示例 输入: heights [1,1,3,3,4,1]输出: 3解释: 经过排序后 heights变成了[1,1,1,3,3,4]#xff0c;有三个学生不在应在…
文章目录1. 题目2. 解题1. 题目
描述 班上的学生根据他们的年级照片的身高升序排列确定当前未站在正确位置的学生人数
数组长度 10^5示例 输入: heights [1,1,3,3,4,1]输出: 3解释: 经过排序后 heights变成了[1,1,1,3,3,4]有三个学生不在应在的位置上来源https://tianchi.aliyun.com/oj/141742855745988779/153294680351772731
2. 解题
复制一份排序跟原来的对比
class Solution {
public:/*** param heights: Students height* return: How many people are not where they should be*/int orderCheck(vectorint heights) {// write your code herevectorint arr heights;sort(heights.begin(), heights.end());int count 0;for(int i 0; i arr.size(); i){if(arr[i] ! heights[i])count;}return count;}
};101ms C 我的CSDN博客地址 https://michael.blog.csdn.net/
长按或扫码关注我的公众号Michael阿明一起加油、一起学习进步