【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 ...
随机推荐
- java之比较器
java中的比较器有两种: 1.实体类实现Comparable接口,并实现其中的compareTo方法 2.在外部定义实现Comparator接口的比较器类,并实现其中的compare方法 Compa ...
- PDB符号文件浏览工具介绍
一.SymView SymView工具用来显示符号文件中包含的符号表和符号数据.目前支持微软的Visual C/C++和C#编译器产生的DBG格式的符号文件和PDB格式的符号文件. SymView提供 ...
- RookeyFrame 还原 软删除的数据 怎么硬删除 或者 怎么还原
列表搜索栏上有个删除图标,可以进入回收站 如图:
- web表单
1.配置 使用Flask-WTF, 它集成了WTForms并且完美地集成到了flask. 在microblog根目录下创建一个文件,存储flask扩展的所有配置,CSRF_ENABLED用于激活跨站点 ...
- P5590 【赛车游戏】
果然我还是太\(Naive\)了 首先有一些点/边其实是没有意义的,如果从1出发不能到该点或者从该点不能到n,这个点就可以不用管了.这个过程可以用正反两边\(dfs/bfs\)实现 然后删掉那些点之后 ...
- 洛谷P5098 洞穴里的牛之三
题目 贪心,可以用分类讨论的方法,可以得出如果\(n^2\)枚举则会过不了,而我们观察原题中的式子,有: \(∣x1−x2∣+∣y1−y2∣\) 发现式子中的绝对值很恶心,而考虑如果没有绝对值的话会有 ...
- ehcache.xml 配置文件备忘录(不建议出现中文注释,此处备忘)
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLoc ...
- Mybatis 代码生成器(集成通用Mapper)
0.确保通用Mapper被正确配置 1.pom.xml追加 <properties> <targetJavaProject>${basedir}/src/main/java&l ...
- mysql group by 报错 ,only_full_group_by 三种解决方案
报错信息 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'data ...
- #C++初学记录(判断子串#数学结合)
A Count Task Problem Description Count is one of WNJXYK's favorite tasks. Recently, he had a very lo ...