当前位置:网站首页>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:28:00 【昔痕】
leetcode167. 两数之和 II - 输入有序数组
java return
相当于声明之后就返回了
返回字符串 return new String(s);
返回数组 return new int[]{-1, -1};
C++
return {low + 1, high + 1};
应该也是返回一个数组
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};
}
};
边栏推荐
- SQL interview question: find the maximum number of consecutive login days
- Autumn recruitment experience sharing | how to prepare for bank interview
- 我是刚购买的adb mysql服务,我每做一个操作,比如建表,都会弹出这个问题,请问这是什么问题?
- Friends from Fujian, your old-age insurance is on the cloud!
- leetcode 1423. Maximum points you can obtain from cards
- 视频压缩处理之ffmpeg用法
- 判断字符串是否为空
- Parallax JS special effect JS carousel map plug-in
- Win11如何给系统盘瘦身?Win11系统盘瘦身方法
- shell读取Json文件的值
猜你喜欢

视频压缩处理之ffmpeg用法

Variational graph auto-encoders (VGAE)

From design delivery to development, it is easy and efficient!

Variable autoencoders (vaes)

Industry analysis - quick intercom, building intercom

180.1. Log in continuously for n days (database)

sql计算每日新增用户、及留存率指标

SQL calculates daily new users and retention rate indicators

变分自编码器 (Variational Autoencoders, VAEs)

智能计算系统3 Plugin 集成开发的demo
随机推荐
sql计算每日新增用户、及留存率指标
Find out the users who log in for 7 consecutive days and 30 consecutive days
道路千万条,为什么这家创新存储公司会选这条?
Try except add auxiliary new column
I just bought the ADB MySQL service. Every time I do an operation, such as creating a table, this problem will pop up. What is the problem?
leetcode 1647. Minimum deletions to make character frequencies unique
行业分析| 快对讲,楼宇对讲
Installation and configuration of CGAL in PCL environment 5.4.1
h5向日葵作业
Brief introduction to mongodb working principle of mongodb series
Constrained Delaunay triangulation in MATLAB
Question brushing analysis tool
首部元宇宙概念小说《元宇宙2086》获得2022年上袭元宇宙奖
找出连续7天登陆,连续30天登陆的用户
腾讯汤道生:面向数实融合新世界,开发者是最重要的“建筑师”
Build halo blog in arm version rk3399
Month on month SQL implementation
leetcode 1423. Maximum points you can obtain from cards
Intelligent computing system 1 environment construction
从设计交付到开发,轻松畅快高效率!