【Leetcode_easy】1051. Height Checker
problem
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的更多相关文章
- 【leetcode】1051. Height Checker
题目如下: Students are asked to stand in non-decreasing order of heights for an annual photo. Return the ...
- 【LeetCode】1051. Height Checker 解题报告(Python & C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 排序比较 日期 题目地址:https://leetc ...
- 【LEETCODE】40、1051. Height Checker
package y2019.Algorithm.array; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array * ...
- 【BZOJ】1051: [HAOI2006]受欢迎的牛(tarjan)
http://www.lydsy.com/JudgeOnline/problem.php?id=1051 这题还好-1A了..但是前提还是看了题解的 囧.....一开始认为是并查集,oh,不行,,无法 ...
- leetcode 1051. Height Checker
Students are asked to stand in non-decreasing order of heights for an annual photo. Return the minim ...
- 【BZOJ1051】1051: [HAOI2006]受欢迎的牛 tarjan求强连通分量+缩点
Description 每一头牛的愿望就是变成一头最受欢迎的牛.现在有N头牛,给你M对整数(A,B),表示牛A认为牛B受欢迎. 这种关系是具有传递性的,如果A认为B受欢迎,B认为C受欢迎,那么牛A也认 ...
- 【BZOJ】1051: [HAOI2006]受欢迎的牛
[HAOI2006]受欢迎的牛 Description 每一头牛的愿望就是变成一头最受欢迎的牛.现在有N头牛,给你M对整数(A,B),表示牛A认为牛B受欢迎. 这种关系是具有传递性的,如果A认为B受欢 ...
- 【POJ】1035 Spell checker
字典树. #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib ...
- 【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 ...
随机推荐
- ElasticSearch使用C#操作文档
一.ElasticSearch的.net客户端驱动程序 ElasticSearch官方网站提供了两个.net客户端驱动程序,其中Elasticsearch.Net是一个非常底层且灵活的客户端驱动程序, ...
- saltstack 基础模块
Salt 在 linux 系统下 基础操作 1.更改权限 # salt 2.更改用户 # salt '172.16.3.9' file.chown /root/test test test 3.复制文 ...
- 关于size
关于size它确实可以帮人算内存 但是: 在不会用到整个数组(尤其是在状压的时候) 不要用它,它只能算你申请了多少内存,但算不了会用多少!!! and 有人能告诉我,交题前不好好看看交的哪份代码是什么 ...
- git 导出远程特定分之
很多时候,git clone 只是 clone 下来了 master 分支,如果想 clone 特定分支.有的时候不知如何是好. 找到了如下的命令,记录一下.以便有需要的同学可以使用. git co ...
- Pytest权威教程-更改标准(Python)测试发现
目录 更改标准(Python)测试发现 在测试收集过程中忽略路径 测试期间收集的测试取消 保留从命令行指定的重复路径 更改目录递归 更改命名约定 将cmdline参数解释为Python包 找出收集的东 ...
- FWT快速沃尔什变换例题
模板题 传送门 #include<bits/stdc++.h> #define ll long long #define max(a,b) ((a)>(b)?(a):(b)) #de ...
- 巧用DNSlog实现无回显注入【转载】
原作者:afanti 原出处:https://www.cnblogs.com/afanti/p/8047530.html 0x00 简介 测试一些网站的时候,一些注入都是无回显的,我们可以写脚本来进行 ...
- PKUWC2020 游记
因为CSP-S挂的并不厉害,蜜汁来到了PKU,所以有了这篇游记. DAY 0 上午在机房颓废,中途还整了一个出校证. 九点多,两个THU的大神去拿笔记本和手机颓废了,不久被两个教练拉着和kx跑了出去. ...
- 2018-2019-2 网络对抗技术 20165212 Exp 8 Web基础
2018-2019-2 网络对抗技术 20165212 Exp 8 Web基础 原理与实践说明 1.实践内容概述 1.Web前端HTML 能正常安装.启停Apache.理解HTML,理解表单,理解GE ...
- mysql innodb与myisam存储文件的区别
myisam: .frm: 存储表定义 .myd(MYData):存储数据 .MYI(MYindex):存储引擎 innodb: .frm:存储表定义 .idb:存储数据和索引,在同一个文件中