class Solution {
public:
vector<int> twoSum(vector<int>& numbers, int target) {
int n = numbers.size();
vector<int> result;
int i = ;
for (i = ;i<n&&numbers[i]<= target;i++){
for (int j = i+;j<n&&numbers[j]<=target;j++){
if (numbers[i]+numbers[j] == target){
result.push_back(i+);
result.push_back(j+);
return result;
}
}
}
return {};
}
};

leetcode 之 Two Sum II - Input array is sorted c++的更多相关文章

  1. 29. leetcode 167. Two Sum II - Input array is sorted

    167. Two Sum II - Input array is sorted Given an array of integers that is already sorted in ascendi ...

  2. [LeetCode] 167. Two Sum II - Input array is sorted 两数和 II - 输入是有序的数组

    Given an array of integers that is already sorted in ascending order, find two numbers such that the ...

  3. LeetCode 167. Two Sum II - Input array is sorted (两数之和之二 - 输入的是有序数组)

    Given an array of integers that is already sorted in ascending order, find two numbers such that the ...

  4. (双指针 二分) leetcode 167. Two Sum II - Input array is sorted

    Given an array of integers that is already sorted in ascending order, find two numbers such that the ...

  5. 【LeetCode】Two Sum II - Input array is sorted

    [Description] Given an array of integers that is already sorted in ascending order, find two numbers ...

  6. LeetCode 167 Two Sum II - Input array is sorted

    Problem: Given an array of integers that is already sorted in ascending order, find two numbers such ...

  7. ✡ leetcode 167. Two Sum II - Input array is sorted 求两数相加等于一个数的位置 --------- java

    Given an array of integers that is already sorted in ascending order, find two numbers such that the ...

  8. Java [Leetcode 167]Two Sum II - Input array is sorted

    题目描述: Given an array of integers that is already sorted in ascending order, find two numbers such th ...

  9. LeetCode - 167. Two Sum II - Input array is sorted - O(n) - ( C++ ) - 解题报告

    1.题目大意 Given an array of integers that is already sorted in ascending order, find two numbers such t ...

  10. LeetCode 167. Two Sum II – Input array is sorted

    Given an array of integers that is already sorted in ascending order, find two numbers such that the ...

随机推荐

  1. Restful风格

    今天看到一个比较好的文章,记录一下: Restful风格API中用put还是post做新增操作有什么区别? 1 HTTP协议详解 HTTP协议通常承载于TCP协议之上,有时也承载于TLS或SSL协议层 ...

  2. Java的家庭记账本程序(L)

    日期:2019.3.13 博客期:044 星期三 整理了两天,我终于也是把微信小程序平台的记账本软件完全开发出来了,并将我的微信账号与GitHub账号完成了绑定,那么我就先展示一部分作品,还有一部分代 ...

  3. day13-迭代器及生成器

    iterable:可迭代的:iterator:迭代器: print(dir([ ]))  #打印出列表所拥有的所有方法: 可迭代协议:只要含有__iter__方法的都是可迭代的. 迭代器协议:含有__ ...

  4. Storm介绍及安装部署

    本节内容: Apache Storm是什么 Apache Storm核心概念 Storm原理架构 Storm集群安装部署 启动storm ui.Nimbus和Supervisor 一.Apache S ...

  5. mysql触发器Before和After的区别

    Before与After区别:before:(insert.update)可以对new进行修改.                    after不能对new进行修改.                 ...

  6. pyspider和pyquery总结

    1.参考 pyspider作者官网: pyspider 爬虫教程(一):HTML 和 CSS 选择器 pyspider 爬虫教程(二):AJAX 和 HTTP pyspider 爬虫教程(三):使用 ...

  7. 一起学爬虫——使用xpath库爬取猫眼电影国内票房榜

    之前分享了一篇使用requests库爬取豆瓣电影250的文章,今天继续分享使用xpath爬取猫眼电影热播口碑榜 XPATH语法 XPATH(XML Path Language)是一门用于从XML文件中 ...

  8. mysql运行报The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone的解决方法

    话不多说,从错误即可知道是时区的错误,因此只要将时区设置为你当前系统时区即可, 因此使用root用户登录mysql,按照如下图所示操作即可. 我电脑的系统为北京时区,因此在系统中设置后,再连接数据库运 ...

  9. 编译linux内核前用make menuconfig设置时 Unable to find the ncurses ibraries的解决办法

    今天在更新CentOS或者Ubuntu的内核时,执行make menuconfig可能看如这样的错误: *** Unable to find the ncurses libraries or the ...

  10. (转)InFluxDB数据库使用手册

    InfluxDB是一个开源的时序数据库,使用GO语言开发,特别适合用于处理和分析资源监控数据这种时序相关数据.而InfluxDB自带的各种特殊函数如求标准差,随机取样数据,统计数据变化比等,使数据统计 ...