747. Largest Number At Least Twice of Others
static int wing=[]()
{
std::ios::sync_with_stdio(false);
cin.tie(NULL);
return ;
}(); class Solution
{
public:
int dominantIndex(vector<int>& nums)
{
int firstmax=INT_MIN,secondmax=INT_MIN,index=-;
int sz=nums.size();
for(int i=;i<sz;i++)
{
if(nums[i]>firstmax)
{
secondmax=firstmax;
firstmax=nums[i];
index=i;
}
else if(nums[i]>secondmax)
secondmax=nums[i];
}
return (firstmax>=*secondmax)? index:-;
}
};
扫描一遍,找出最大和第二大的就行了
747. Largest Number At Least Twice of Others的更多相关文章
- 【Leetcode_easy】747. Largest Number At Least Twice of Others
problem 747. Largest Number At Least Twice of Others 题意: solution1: class Solution { public: int dom ...
- [LeetCode] 747. Largest Number At Least Twice of Others_Easy
In a given integer array nums, there is always exactly one largest element. Find whether the largest ...
- 747. Largest Number At Least Twice of Others比所有数字都大两倍的最大数
[抄题]: In a given integer array nums, there is always exactly one largest element. Find whether the l ...
- leetcode 747. Largest Number At Least Twice of Others
In a given integer array nums, there is always exactly one largest element. Find whether the largest ...
- 【LeetCode】747. Largest Number At Least Twice of Others 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 寻找两次最大值 排序 大顶堆 日期 题目地址:htt ...
- Java 特定规则排序-LeetCode 179 Largest Number
Given a list of non negative integers, arrange them such that they form the largest number. For exam ...
- [LeetCode] Largest Number 最大组合数
Given a list of non negative integers, arrange them such that they form the largest number. For exam ...
- 【leetcode】Largest Number
题目简述: Given a list of non negative integers, arrange them such that they form the largest number. Fo ...
- leetcode 179. Largest Number 求最大组合数 ---------- java
Given a list of non negative integers, arrange them such that they form the largest number. For exam ...
随机推荐
- Wasserstein距离
https://blog.csdn.net/leviopku/article/details/81388306 https://blog.csdn.net/nockinonheavensdoor/ar ...
- 发送邮件【文本-html】【图片】【邮件】【附件】
依赖 <!-- https://mvnrepository.com/artifact/javax.mail/mail --> <dependency> <groupId& ...
- 【转】 UI自动化测试的关注点
我发现了,大家极度关心自动化测试,尤其是UI自动化测试,虽然现在作为专项测试,离开这些越来越远了,但总能遥想以前,我总能想起自己做nokia的WindowsLive的ui自动化,做web的自动化测试, ...
- [Unity3D]降低向Shader中传值的开销
Unity3D中提供了很多API用于向shader传值,这篇文章对比测试了两类不同的使用方法的性能. 正文 Unity3D中,通过C#代码向shader传值有两种方式. 一种是面向具体的materia ...
- WLC5520无法通过无线客户端进行网管故障解决
客户反馈其办公环境中的WLC5520网管需要通过内部有线网络进行管理,通过无线客户端无法进行管理,远程协助其开启WLC5520的无线管理功能后故障解决.
- Django的auth【认证】模块简介
首先我们先来复习一下路由别名如何使用,这里仅仅复习一下二级路由的路由别名该如何使用 ·1.在视图函数中使用二级路由别名,需要加上app的名称+“:”+ “路由别名” from django.urls ...
- mac navicat premium 使用技巧
快捷键 CMD-I:对象信息 CMD-L:查询日志 CMD-Y:新建查询 SHIFT-CMD-T:数据传输 SHIFT-CMD-C:命令列界面
- python脚本linux上后台执行
1.脚本后加& 加了&以后可以使脚本在后台运行,这样的话你就可以继续工作了.但是有一个问题就是你关闭终端连接后,脚本会停止运行 python3 run.py >/dev/null ...
- Java09-java语法基础(八)java中的方法
Java09-java语法基础(八)java中的方法 一.方法(函数/过程):是一个程序块,可以完成某种功能 1.java中方法的定义格式 [访问控制修饰符] 返回值类型 方法名(参数列表){ 方 ...
- __block的初步用法
再block中使用 self 时,要在前面加上__block. 防止在block中用到self时把self对象retain, 造成内存泄露. __block UIViewController *saf ...