问题描述

解决方案


class Solution {
public:vector<int> twoSum(vector<int>& numbers, int target) {int index1=0,index2=numbers.size()-1;while(index1<index2){if((numbers[index1]+numbers[index2])==target) break;else if((numbers[index1]+numbers[index2])>target) --index2;else++index1;}return vector<int> {index1+1,index2+1};}
};

转载于:https://www.cnblogs.com/ucas/p/5800769.html

167. Two Sum II - Input array is sorted相关推荐

  1. 167. Two Sum II - Input array is sorted (C, C++, Python)

    本文讲述了Array类中第167个问题的几种解法,实现语言包括C,Python以及C++. 问题: Given an array of integers that is already sorted ...

  2. 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 tha ...

  3. leetcode python3 简单题167. Two Sum II - Input array is sorted

    1.编辑器 我使用的是win10+vscode+leetcode+python3 环境配置参见我的博客: 链接 2.第一百六十七题 (1)题目 英文: Given an array of intege ...

  4. [LeetCode By Python]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 ...

  5. 【LeetCode 剑指offer刷题】数组题2:57 有序数组中和为s的两个数(167 Two Sum II - Input array is sorted)...

    [LeetCode & 剑指offer 刷题笔记]目录(持续更新中...) 57 有序数组中和为s的两个数 题目描述 输入一个递增排序的数组和一个数字S,在数组中查找两个数,是的他们的和正好是 ...

  6. 167. Two Sum II - Input array is sorted 两数之和 II - 输入有序数组

    Title 给定一个已按照升序排列 的有序数组,找到两个数使得它们相加之和等于目标数. 函数应该返回这两个下标值 index1 和 index2,其中 index1 必须小于 index2. 说明: ...

  7. leetcode 167 Two Sum II - Input array is sorted

    给定一个有序的数组,和一个整数目标,求两个数的和等于目标的索引,索引从1开始.假设必定存在解. 有两种思路: 直接找: vector<int> twoSum(vector<int&g ...

  8. 167. Two Sum II - Input array is sorted两数之和

    1. 原始题目 给定一个已按照升序排列 的有序数组,找到两个数使得它们相加之和等于目标数. 函数应该返回这两个下标值 index1 和 index2,其中 index1 必须小于 index2. 说明 ...

  9. LeetCode 167. Two Sum II - Input array is sorted--Python解法

    题目地址:Two Sum II - Input array is sorted - LeetCode Given an array of integers that is already sorted ...

最新文章

  1. C语言实现的Web服务器(转-kungstriving)
  2. java中日期计算时间差,用java计算日期/时间差
  3. Discuz升级 Database Error : pre_common_syscache ADD PRIMARY KEY (cname)【解决办法】
  4. SD初始化过程以及Cmd解析
  5. C#Winform窗体实现服务端和客户端通信例子(TCP/IP)
  6. 本科是最底层?学历真的那么重要么?
  7. Python 字符串和列表的转化 ,简单到尖叫
  8. 华为云龙api自动化工具_聊聊华为GDE刚发布的一体化低门槛开发平台ADC 2.0
  9. JSch连接不上Linux服务器,JSch链接linux服务器问题解决方案:Session.connect: java.io.IOException: End of IO Stream Read...
  10. 知识分享 | 卡方分析的入门小知识
  11. Hive 字符串转日期
  12. 江西省谷歌高清卫星地图下载
  13. 今天看了了一下手册,先弄清楚芯片脚功能
  14. k2ttl救砖_无线路由救砖 ttl刷机教程
  15. 怎样设置默认打印机(HttpPrinter 易桥打印中间件)
  16. html怎么给图片加倒影,用CSS3实现图片倒影效果,同时给出兼容早期版本IE的方案...
  17. SpringBoot22-spingboot数据访问-Spring Data JPA
  18. pg创建数据库和用户并授权
  19. 阿里云大学-虚拟化技术入门-听课笔记
  20. 清华计算机考研复试机试,清华大学历年考研复试机试真题 - 论文

热门文章

  1. 对JavaScript内置对象arguments的一些见解
  2. TF实战:(Mask R-CNN原理介绍与代码实现)-Chapter-8
  3. 推荐系统入门:作为Rank系统的推荐系统(协同过滤)
  4. Boost正则表达式
  5. [ASP.NET MVC 小牛之路]01 - 理解MVC模式
  6. zabbix针对目录监控
  7. YII中session和cookie
  8. linux系统安全详解
  9. 无法解析的外部符号的几种可能(lib方面的)(还有dll方面的,不在本文中)...
  10. Android——Fragment介绍