当前位置:网站首页>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};
}
};
边栏推荐
- Kettle (VI): full database backup based on kettle
- Technical methodology of new AI engine under the data infrastructure upgrade window
- Time series forecasting based on trend and seasonality
- 国内有正规安全的外汇交易商吗?
- C#连接数据库完成增删改查操作
- Jenkins Pipeline 对Job参数的处理
- 100人成绩的平均
- Bayesian inference problem, MCMC and variational inference
- Web3 that unleashes the value of the Internet
- kettle(六):基于Kettle的数据库全量备份
猜你喜欢

The white paper on the panorama of the digital economy and the digitalization of consumer finance were released

Question brushing analysis tool

Win11底部状态栏如何换成黑色?Win11底部状态栏换黑色的方法

Month on month SQL implementation

How to remove dataframe field column names

Variational graph auto-encoders (VGAE)

易观分析《2022年中国银行业隐私计算平台供应商实力矩阵分析》研究活动 正式启动

Demo of intelligent computing system 2 bangc operator development (heterogeneous programming flow of CPU and mlu270)

图神经网络入门 (GNN, GCN)

math_ Proving common equivalent infinitesimal & Case & substitution
随机推荐
行业分析| 快对讲,楼宇对讲
return new int[]{i + 1, mid + 1};return {i + 1, mid + 1};
Build halo blog in arm version rk3399
Ffmpeg learning summary
国内有正规安全的外汇交易商吗?
Kaggle gastrointestinal image segmentation competition baseline
[C #] explain the difference between value type and reference type
如何通过W3school学习JS/如何使用W3school的JS参考手册
在arm版本rk3399中搭建halo博客
数据基础设施升级窗口下,AI 新引擎的技术方法论
i人事HR系统上架企业微信ISV,增强企微在服务连锁零售等行业深度应用
【324. 摆动排序 II】
SQL Server2019 新建 SQL Server身份验证用户名 并登录
PCL 计算平面三角形外接圆的圆心和半径
The amazing nanopc-t4 (rk3399) is used as the initial configuration and related applications of the workstation
多测师肖sirapp中riginal error: Could not extract PIDs from ps output. PIDS: [], Procs: [“bad pid
SQL interview question: find the maximum number of consecutive login days
Why is it not enough to declare the structure alias when using the structure variable of other files in C language, and the proper name must be used? (cannot add struct when using alias)
华为云OneMeeting告诉你全场景会议这么开!
Constrained Delaunay triangulation in MATLAB