当前位置:网站首页>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};
}
};
边栏推荐
- PCL 计算平面三角形外接圆的圆心和半径
- 深度学习需要多强的数学基础?
- Web3 that unleashes the value of the Internet
- i人事HR系统上架企业微信ISV,增强企微在服务连锁零售等行业深度应用
- C语言-函数知识点
- NanoPC-T4(RK3399) game1 oled(I2C)显示时间天气温度
- Brief introduction to mongodb working principle of mongodb series
- 数字藏品,万字长文,你想知道的大部分问题都讲清楚了从业者必看
- Sound network releases lingfalcon Internet of things cloud platform, which can build sample scenarios in one hour
- Friends from Fujian, your old-age insurance is on the cloud!
猜你喜欢

How to remove dataframe field column names

There are thousands of roads. Why did this innovative storage company choose this one?

math_ Proving common equivalent infinitesimal & Case & substitution

Group programming TIANTI competition exercise - continuously updating

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

High performance and high availability computing architecture scheme commented by Weibo

Tencent tangdaosheng: facing the new world of digital and real integration, developers are the most important "architects"

Graduation project - Design and development of restaurant management game based on unity (with source code, opening report, thesis, defense PPT, demonstration video and database)

大火的虚拟人在哪些产业开始发力?

首部元宇宙概念小说《元宇宙2086》获得2022年上袭元宇宙奖
随机推荐
Month on month SQL implementation
How does the computer check whether the driver is normal
mysql全解 Ubuntu/win10
List adding timer (positive and countdown)
180.1. Log in continuously for n days (database)
让企业数字化砸锅和IT主管背锅的软件供应链安全风险指南
Hands on Teaching of servlet use (1)
Show the actual work case of creating intermediate data table with SQL
Double contextual relationship network for polyp segmentation
pd. Difference between before and after cut interval parameter setting
MDM数据分析功能说明
Render function parsing
几行代码就能实现复杂的 Excel 导入导出,这个工具类真心强大!
NanoPC-T4(RK3399) game1 oled(I2C)显示时间天气温度
Bayesian inference problem, MCMC and variational inference
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
Upward and downward transformation
How does win11 slim down the system disk? Slimming method of win11 system disk
Figure introduction to neural networks (GNN, GCN)
论文3 VScode&texlive&SumatraPDF打造完美书写论文工具