problem

1051. Height Checker

solution

class Solution {
public:
int heightChecker(vector<int>& heights) {
vector<int> orders = heights;
sort(orders.begin(), orders.end());
int res = ;
for(int i=; i<heights.size(); i++)
{
if(heights[i]!=orders[i]) res++;
}
return res;
}
};

参考

1. Leetcode_easy_1051. Height Checker;

【Leetcode_easy】1051. Height Checker的更多相关文章

  1. 【leetcode】1051. Height Checker

    题目如下: Students are asked to stand in non-decreasing order of heights for an annual photo. Return the ...

  2. 【LeetCode】1051. Height Checker 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 排序比较 日期 题目地址:https://leetc ...

  3. 【LEETCODE】40、1051. Height Checker

    package y2019.Algorithm.array; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array * ...

  4. 【BZOJ】1051: [HAOI2006]受欢迎的牛(tarjan)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1051 这题还好-1A了..但是前提还是看了题解的 囧.....一开始认为是并查集,oh,不行,,无法 ...

  5. leetcode 1051. Height Checker

    Students are asked to stand in non-decreasing order of heights for an annual photo. Return the minim ...

  6. 【BZOJ1051】1051: [HAOI2006]受欢迎的牛 tarjan求强连通分量+缩点

    Description 每一头牛的愿望就是变成一头最受欢迎的牛.现在有N头牛,给你M对整数(A,B),表示牛A认为牛B受欢迎. 这种关系是具有传递性的,如果A认为B受欢迎,B认为C受欢迎,那么牛A也认 ...

  7. 【BZOJ】1051: [HAOI2006]受欢迎的牛

    [HAOI2006]受欢迎的牛 Description 每一头牛的愿望就是变成一头最受欢迎的牛.现在有N头牛,给你M对整数(A,B),表示牛A认为牛B受欢迎. 这种关系是具有传递性的,如果A认为B受欢 ...

  8. 【POJ】1035 Spell checker

    字典树. #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib ...

  9. 【PAT】1051 Pop Sequence (25)(25 分)

    Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and p ...

随机推荐

  1. neo4j索引

    1.创建索引 CREATE INDEX ON : Disease (name) 2.查询所有创建的索引 :schema 或者 call db.indexes 3.删除索引 drop index on ...

  2. React vs Angular vs Vue 2019

    React vs Angular vs Vue 看待这三个主流框架给出的想法 Angular is the entire kitchen that gives you all the tools ne ...

  3. 正确使用Java读写锁

    JDK8中引入了高性能的读写锁StampedLock,它的核心思想在于,在读的时候如果发生了写,应该通过重试的方式来获取新的值,而不应该阻塞写操作.这种模式也就是典型的无锁编程思想,和CAS自旋的思想 ...

  4. luogu P1058 立体图

    做了这个题后明确了自己的定位... 恩...普及- 题目大意估计都知道.. 给个传送门:   luogu 做了半上午 + 一整个下午的题... 占了我今天到的绝大多数时间. 其实此题不难, 核心代码我 ...

  5. flutter 监听返回

    在项目中遇到了一个场景,A页面必须返回某个tab页,但是A页面可能会调到B,再跳到C,最后回到A.这个时候A的返回肯定是C. 想了一些解决方案,都不如监听A页面的实体键返回或者虚拟键返回来的快速便捷. ...

  6. listview1 保存和读取 listViewItems保存为txt

       /*          *   保存原理          *   将LISTVIEW视为一行一行的字符串          *   将所有的行合并成一个字符串 然后保存为TXT文件       ...

  7. 使用清华源 tensorflow 安装

    1. 超级权限打开cmd.exe 2. pip install --upgrade setuptools 3.  pip install -U --ignore-installed wrapt enu ...

  8. IdHTTPServer允许跨域访问

    IdHTTPServer允许跨域访问 procedure TMain.idHttpServerCommandGet(AContext: TIdContext; ARequestInfo: TIdHTT ...

  9. mysql查看数据库表数量

    1.查看数据库表数量SELECT count(TABLE_NAME) FROM information_schema.TABLES WHERE TABLE_SCHEMA='dbname'; selec ...

  10. GB28181技术基础之1 - SIP协议

    SIP 协议,即 会话初始协议(Session Initiation Protocol),是一个应用层的 点对点协议,用于初始.管理和终止网络中的语音和视频会话,是 GB28181 的核心之一. 按照 ...