// 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. sqlmap用户手册

    http://192.168.136.131/sqlmap/mysql/get_int.php?id=1 当给sqlmap这么一个url的时候,它会: 1.判断可注入的参数2.判断可以用那种SQL注入 ...

  2. JS判断input按了回车键

    参考代码如下: <input type="textbox" id="textbox1" onkeypress="CheckInfo" ...

  3. NSJSONSerialization 组json字符串

    抄的网上的. 主要是组织列表部分 NSDictionary *song = [NSDictionary dictionaryWithObjectsAndKeys:",@"lengt ...

  4. vim的树形菜单NERDTREE的设置

    网上比较好的一篇文章:http://coolshell.cn/articles/1679.html http://coolshell.cn/articles/11312.html 1.Vim安装NER ...

  5. C# 标准差计算

    if (numberList.Any()) { exEntity.MinValue = numberList.First().NumberValue.ToString(); exEntity.MaxV ...

  6. ajax同步异步问题

    之前一直在写JQUERY代码的时候遇到AJAX加载数据都需要考虑代码运行顺序问题.最近的项目用了到AJAX同步.这个同步的意思是当JS代码加载到当前AJAX的时候会把页面里所有的代码停止加载,页面出去 ...

  7. RichEdit 追加 RTF

    下面实现追加RTF 到 RichEdit 的功能其本质是:EM_STREAMIN 消息,详细查看 MSDN//--------------------------------------------- ...

  8. 【java基础学习二】 数组相互转换,转成用逗号隔开的字符串等

    /** * int[],Integer[],List,List<Integer>,HashSet<Integer>相互转换,转成用逗号隔开的字符串 */ public stat ...

  9. ---awk 调shell 命令的方法

    cat /etc/passwd | awk -F: '/root/{ system ("echo "$1) }'

  10. css3新属性

    CSS calc()函数来制作响应式网格: calc是英文单词calculate(计算)的缩写,是css3的一个新增的功能,你可以使用calc()给元素的border.margin.pading.fo ...