【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 ...
随机推荐
- .NetCore WebApi结构及前端访问方式
.NetCore WebApi结构及前端访问方式(Ajax方式,fetch方式,axios方式) //访问的地址api/控制器名称/方法名称;action一般会省略 [Route("api/ ...
- CentOS 7.5静默安装oracle 11g
1.安装前环境准备 1.1.配置本地yum源 #因公司内网环境,没有互联网,所以需要配置本地yum源,安装所需依赖包等. #挂载ios镜像centos7.5-1804 [root@oracle ~]# ...
- SQL 删除字段 增加字段
SQL增加字段需要用到sql语句 ALTER TABLE 加(表格名称) ADD 加(字段名称) 加(字段类型)实例:ALTER TABLE T_Basic ADD SEODescription Nv ...
- Windows系统错误处理机制
一.什么是错误 意为意为不正确,与正确答案相反.我们这里讲的是Windows操作系统里进程运行时产生的错误.对我们程序员来说,其实也就是我们编程过程中,调用Windows系统提供的API.COM 接口 ...
- noi.ac #30 思维
\(des\) 给定升序数组 \(A, B\) 对于任意两个集合 \(a, b\) 分别是 \(A, B\) 的子集,总价值为较小的集合的和, 总代价为 \((|a| + |b|) \times w\ ...
- 交互设计算法基础(2) - Selection Sort
int[] selection_sort(int[] arr) { int i, j, min, temp, len=arr.length; for (i=0; i<len-1; i++) { ...
- GoCN每日新闻(2019-09-27)
1. Golang新版本发布:Go 1.13.1和Go 1.12.10https://golang.org/dl/ 2. 如何在Golang中使用Websockets:最佳工具和步骤指南 https: ...
- jquery 如何在js中间加入css?
) { $() + 'rem' }) } ) { $( + '%' }) }
- 2018-2019-2 网络对抗技术 20165322 Exp7 网络欺诈防范
2018-2019-2 网络对抗技术 20165322 Exp7 网络欺诈防范 目录 实验原理 实验内容与步骤 简单应用SET工具建立冒名网站 ettercap DNS spoof 结合应用两种技术, ...
- 从Windows命令行启动MySQL
SERVER: 从Windows命令行启动MySQL 可以从命令行手动启动MySQL服务器.可以在任何版本的Windows中实现. 要想从命令行启动mysqld服务器,你应当启动控制台窗口(或“DOS ...