// Java
     public int[] twoSum(int[] nums, int target) {
         int[] answer = new int[2];
         for (int i = 0; i < nums.length; i ++) {
             int j = i + 1;
             for (; j < nums.length; j ++) {
                 if (nums[i] + nums[j] == target) {
                     answer[0] = i;
                     answer[1] = j;
                     return answer;
                 }
             }
         }
         return answer;
     }

1 Two Sum的更多相关文章

  1. LeetCode - Two Sum

    Two Sum 題目連結 官網題目說明: 解法: 從給定的一組值內找出第一組兩數相加剛好等於給定的目標值,暴力解很簡單(只會這樣= =),兩個迴圈,只要找到相加的值就跳出. /// <summa ...

  2. Leetcode 笔记 113 - Path Sum II

    题目链接:Path Sum II | LeetCode OJ Given a binary tree and a sum, find all root-to-leaf paths where each ...

  3. Leetcode 笔记 112 - Path Sum

    题目链接:Path Sum | LeetCode OJ Given a binary tree and a sum, determine if the tree has a root-to-leaf ...

  4. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  5. BZOJ 3944 Sum

    题目链接:Sum 嗯--不要在意--我发这篇博客只是为了保存一下杜教筛的板子的-- 你说你不会杜教筛?有一篇博客写的很好,看完应该就会了-- 这道题就是杜教筛板子题,也没什么好讲的-- 下面贴代码(不 ...

  6. [LeetCode] Path Sum III 二叉树的路径和之三

    You are given a binary tree in which each node contains an integer value. Find the number of paths t ...

  7. [LeetCode] Partition Equal Subset Sum 相同子集和分割

    Given a non-empty array containing only positive integers, find if the array can be partitioned into ...

  8. [LeetCode] Split Array Largest Sum 分割数组的最大值

    Given an array which consists of non-negative integers and an integer m, you can split the array int ...

  9. [LeetCode] Sum of Left Leaves 左子叶之和

    Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two l ...

  10. [LeetCode] Combination Sum IV 组合之和之四

    Given an integer array with all positive numbers and no duplicates, find the number of possible comb ...

随机推荐

  1. 在网页中怎样给已发布的Flash添加链接的方法(zhuan)

    因为网页中的 Flash 是以控件形式出现的,优先级别较高,所以直接对它加链接是无效的,不过可以用按钮控件 BUTTON 来实现. 具体步骤 1.直接在按钮上加上onClick事件打开指定页面: &l ...

  2. Hadoop_配置_linux下编译eclipse插件

    使用的hadoop版本为hadoop-1.2.1(对应的含源码的安装包为hadoop-1.2.1.tar.gz) 将hadoop和eclipse都解压在home中的用户目录下 /home/chen/h ...

  3. SQLServer异步调用,批量复制

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  4. 慕课网-Java入门第一季-7-3 Java 中无参带返回值方法的使用

    来源:http://www.imooc.com/code/1579 如果方法不包含参数,但有返回值,我们称为无参带返回值的方法. 例如:下面的代码,定义了一个方法名为 calSum ,无参数,但返回值 ...

  5. Android自动化学习笔记之MonkeyRunner:用Eclipse执行MonkeyRunner脚本

    Info: 初步学习,难免会有疏漏,以后我会不断修改补全,直到完美.转载请注明出处,谢谢. 2014-10-11: 初版 2014-10-16: 完善 ------------------------ ...

  6. ios 给图片添加水印

    //第一种添加水印方法 -(UIImage *)watermarkImage:(UIImage *)img withName:(NSString *)name{ NSString* mark = na ...

  7. Json 字符串 转换为 DataTable数据集合

    /// <summary> /// 将json转换为DataTable /// </summary> /// <param name="strJson" ...

  8. CSS3按钮鼠标悬浮光圈效果

    1 .HTML相关知识点  HTML(超文本标记语言)是网页的核心.首先你要学会,不要害怕,HTML很容易学习的,刚开始多记多练,但是到最后还是要自己深入专研,简单的入门是很快,但学好HTML是成为W ...

  9. ThinkPad W520 在 Windows Server 2012 / R2 中安装驱动

    1.安装Intel Chipset Device Software (INF Update Utility).2.安装ThinkPad ACPI电源管理驱动.3.安装电源管理软件.4.安装英特尔核芯显 ...

  10. Bootstrap文件上传插件File Input的使用

    基于Metronic的Bootstrap开发框架经验总结(5)--Bootstrap文件上传插件File Input的使用 Bootstrap文件上传插件File Input是一个不错的文件上传控件, ...