当前位置:网站首页>return new int[]{i + 1, mid + 1}; return {i + 1, mid + 1};
return new int[]{i + 1, mid + 1}; return {i + 1, mid + 1};
2022-06-28 19:34:00 【Old mark】
leetcode167. Sum of two numbers II - Input an ordered array 
java return
It is equivalent to returning after declaration
Return string return new String(s);
Returns an array of return new int[]{-1, -1};
C++
return {low + 1, high + 1};
It should also return an array
class Solution {
public int[] twoSum(int[] numbers, int target) {
int low = 0, high = numbers.length - 1;
while (low < high) {
int sum = numbers[low] + numbers[high];
if (sum == target) {
return new int[]{
low + 1, high + 1};
} else if (sum < target) {
++low;
} else {
--high;
}
}
return new int[]{
-1, -1};
}
}
class Solution {
public:
vector<int> twoSum(vector<int>& numbers, int target) {
int low = 0, high = numbers.size() - 1;
while (low < high) {
int sum = numbers[low] + numbers[high];
if (sum == target) {
return {
low + 1, high + 1};
} else if (sum < target) {
++low;
} else {
--high;
}
}
return {
-1, -1};
}
};
边栏推荐
- Bayesian inference problem, MCMC and variational inference
- 令人惊艳的NanoPC-T4(RK3399)作为工作站的初始配置和相关应用
- Question brushing analysis tool
- Analysys analytics' 2022 China Banking privacy computing platform supplier strength matrix analysis' research activity was officially launched
- Kaggle gastrointestinal image segmentation competition baseline
- SQL interview question: find the maximum number of consecutive login days
- Ffmpeg learning summary
- 道路千万条,为什么这家创新存储公司会选这条?
- 论文笔记:Universal Value Function Approximators
- NanoPC-T4(RK3399) game1 oled(I2C)显示时间天气温度
猜你喜欢

Digital collection, ten thousand words long text, most of the questions you want to know have been clearly explained, which must be seen by practitioners

pd. Difference between before and after cut interval parameter setting

Variational graph auto-encoders (VGAE)

Win11如何给系统盘瘦身?Win11系统盘瘦身方法

I. The HR system is put on the enterprise wechat ISV to enhance the in-depth application of enterprise wechat in service chain retail and other industries

SQL interview question: find the maximum number of consecutive login days

秋招经验分享 | 银行笔面试该怎么准备

i人事HR系统上架企业微信ISV,增强企微在服务连锁零售等行业深度应用

在arm版本rk3399中搭建halo博客

R语言GLM广义线性模型:逻辑回归、泊松回归拟合小鼠临床试验数据(剂量和反应)示例和自测题
随机推荐
SQL Server2019 新建 SQL Server身份验证用户名 并登录
秒杀系统设计
How does redis implement inventory deduction? How to prevent oversold?
Full MySQL solution ubuntu/win10
Ffmpeg usage in video compression processing
Demo of intelligent computing system 2 bangc operator development (heterogeneous programming flow of CPU and mlu270)
Variational graph auto-encoders (VGAE)
How to learn JS through w3school / how to use the JS reference manual of w3school
小白创业做电商,选对商城系统很重要!
Facts / assertions / assertions / conclusions / assertions / judgments
Markdown绘图mermaid实用教程
智能计算系统1 环境搭建
Friends from Fujian, your old-age insurance is on the cloud!
How does win11 slim down the system disk? Slimming method of win11 system disk
易观分析《2022年中国银行业隐私计算平台供应商实力矩阵分析》研究活动 正式启动
Installation and configuration of CGAL in PCL environment 5.4.1
列表加入计时器(正计时、倒计时)
Rigid error: could not extract PIDs from PS output PIDS: [], Procs: [“bad pid
Ffmpeg learning summary
Win11底部状态栏如何换成黑色?Win11底部状态栏换黑色的方法