当前位置:网站首页>Get the details of the next largest number
Get the details of the next largest number
2022-07-02 05:19:00 【[email protected]】
6005. Minimum Operations to Make the Array Alternating
First weekly match
The overall idea of this question is relatively simple
But at that time, there was a problem when obtaining the second most frequent number, which led to a continuous wa
for (iter = a.begin(); iter != a.end(); iter++)
{
if (iter->second>maxa)
{
maxa2=maxa;
maxa=iter->second;
}
}
The first version of the code didn't turn around
I thought that the next largest number inherited the previous number and became ok
As everyone knows, a bunch of values will be missed in the process of circular comparison
Therefore, we should increase the judgment conditions for the next largest number
for (iter = a.begin(); iter != a.end(); iter++)
{
if (iter->second>maxa)
{
maxa2=maxa;
maxa=iter->second;
}
else if(iter->second>maxa2)
maxa2=iter->second;
}
版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202151846408037.html
边栏推荐
- Case sharing | intelligent Western Airport
- Line by line explanation of yolox source code of anchor free series network (7) -- obj in head_ loss、Cls_ Loss and reg_ Calculation and reverse transmission of loss I
- Nodejs (03) -- custom module
- Storage of data
- Fabric. JS basic brush
- The El cascader echo only selects the questions that are not displayed
- LeetCode 1175. 质数排列(质数判断+组合数学)
- No logic is executed after the El form is validated successfully
- leetcode存在重复元素go实现
- Exercise notes 13 (effective letter ectopic words)
猜你喜欢
Pyechats 1.19 generate a web version of Baidu map
Gee series: unit 8 time series analysis in Google Earth engine [time series]
2022 Alibaba global mathematics competition, question 4, huhushengwei (blind box problem, truck problem) solution ideas
Gee series: Unit 3 raster remote sensing image band characteristics and rendering visualization
Gee series: Unit 5 remote sensing image preprocessing [GEE grid preprocessing]
Mysql基础---查询(1天学会mysql基础)
MySQL foundation --- query (learn MySQL foundation in 1 day)
Fabric.js IText 手动设置斜体
Gee series: unit 9 generate sampling data in GEE [random sampling]
Nodejs (03) -- custom module
随机推荐
How matlab marks' a 'in the figure and how matlab marks points and solid points in the figure
Using QA band and bit mask in Google Earth engine
Gee: remote sensing image composite and mosaic
LeetCode 241. 为运算表达式设计优先级(分治/记忆化递归/动态规划)
Gee dataset: chirps pentad high resolution global grid rainfall dataset
案例分享|智慧化的西部机场
Fabric.js 圆形笔刷
Leetcode basic programming: array
Global and Chinese markets for marine selective catalytic reduction systems 2022-2028: Research Report on technology, participants, trends, market size and share
Differential identities (help find mean, variance, and other moments)
Map in JS (including leetcode examples)
php/js cookie共享跨域的问题
ubuntu20.04安装mysql8
【pyinstaller】_ get_ sysconfigdata_ name() missing 1 required positional argument: ‘check_ exists‘
Fabric.js IText设置指定文字的颜色和背景色
Gee data set: export the distribution and installed capacity of hydropower stations in the country to CSV table
Global and Chinese market of pressure gauges 2022-2028: Research Report on technology, participants, trends, market size and share
Go implements leetcode rotation array
There are duplicate elements in leetcode. Go implementation
Gee series: unit 6 building various remote sensing indexes in Google Earth engine