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. 转载一篇好理解的vue ssr文章

    转载:原文链接https://www.86886.wang/detail/5b8e6081f03d630ba8725892,谢谢作者的分享 前言 大多数Vue项目要支持SSR应该是为了SEO考虑,毕竟 ...

  2. Python-Django 模型层-单表查询

    单表操作 -增加,删,改:两种方式:queryset对象的方法,book对象的方法 -改:需要用save() -get()方法:查询的数据有且只有一条,如果多,少,都抛异常 单表查询 -<1&g ...

  3. SQL数据库分页OFFSET FETCH NEXT

    SELECT * FROM dbo.UMS_System_Menu AS USM ORDER BY USM.MenuCode OFFSET ROW --跳过前10条 ROW ONLY --取20条

  4. Python实现字符串反转的几种方法

    面试遇到的一个特无聊的问题--- 要求:在Python环境下用尽可能多的方法反转字符串,例如将s = "abcdef"反转成 "fedcba" 第一种:使用字符 ...

  5. c++中字符串的反转

    1.对于用char定义的字符串:使用string.h中的strrev函数 #include <iostream> #include <cstring> using namesp ...

  6. 机器学习之--KNN算法简单实现

    # # kNN 分类算法 a = np.array([[1,1],[1.2,1.5],[0.3,0.4],[0.2,0.5]]) #构造样本数据 labels = ['A','A','B','B'] ...

  7. debian安装redis

    添加rc.local文件cat </etc/rc.local#!/bin/sh -eexit 0EOF cd /opt wget http://download.redis.io/release ...

  8. flask + MySQL-python 创建 webapp 应用

    0 - python 用自带的 wgsi 也可以创建 web 服务1)建立 hello.py 内容如下 # hello.pydef application(environ, start_respons ...

  9. 【BZOJ1103】大都市 解题报告

    题目传送门 打算5分钟写完题解 题目大意 有一棵n个点的有根树, 初始时每条边均为红色,有两种操作: 把某条边染为蓝色 统计根到某一点路径上的红边数量 思路 用\(a_i\)表示根到点i路径上的红边数 ...

  10. centos7安装nginx-1.13.6 新手入门,图文解析

    系统环境 操作系统:64位CentOS Linux release 7.2.1511 (Core) 安装nginx依赖包 [root@localhost ~]# yum install gcc-c++ ...