当前位置:网站首页>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
边栏推荐
- Fabric. JS round brush
- 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
- Gee series: Unit 4 data import and export in Google Earth engine
- 画波形图_数字IC
- No logic is executed after the El form is validated successfully
- 线程池批量处理数据
- 【pyinstaller】_ get_ sysconfigdata_ name() missing 1 required positional argument: ‘check_ exists‘
- 2022 Alibaba global mathematics competition, question 4, huhushengwei (blind box problem, truck problem) solution ideas
- Fabric. JS 3 APIs to set canvas width and height
- Global and Chinese market of impact roll 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢

【pyinstaller】_ get_ sysconfigdata_ name() missing 1 required positional argument: ‘check_ exists‘

运维工作的“本手、妙手、俗手”

Fabric.js IText 手动设置斜体

Mysql基础---查询(1天学会mysql基础)

Mathematical problems (number theory) trial division to judge prime numbers, decompose prime factors, and screen prime numbers

黑马笔记---Map集合体系

Creation and destruction of function stack frames

Principle and implementation of parallax effect

Fabric. JS iText sets the color and background color of the specified text

LeetCode 241. 为运算表达式设计优先级(分治/记忆化递归/动态规划)
随机推荐
Go implements leetcode rotation array
Gee: use of common mask functions in remote sensing image processing [updatemask]
MySQL foundation --- query (learn MySQL foundation in 1 day)
7.1模擬賽總結
Fabric. JS three methods of changing pictures (including changing pictures in the group and caching)
Gee series: Unit 3 raster remote sensing image band characteristics and rendering visualization
6. Network - Foundation
js中的Map(含leetcode例题)
Gee series: unit 6 building various remote sensing indexes in Google Earth engine
How matlab marks' a 'in the figure and how matlab marks points and solid points in the figure
数据库批量插入数据
Principle and implementation of parallax effect
Fabric. JS upload local image to canvas background
【pyinstaller】_get_sysconfigdata_name() missing 1 required positional argument: ‘check_exists‘
ubuntu20.04安装mysql8
leetcode存在重复元素go实现
黑馬筆記---Set系列集合
Black Horse Notes - - set Series Collection
Mapping settings in elk (8) es
Global and Chinese market of cell culture freezers 2022-2028: Research Report on technology, participants, trends, market size and share