// 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. python download

    今天下载 python3 , 从官网下 速度 平均 十几K,网上 搜了下.提供的下载地址 几乎都是 官网的. 于是 下了个 百度同步盘,做 公开分享. 提供给 大家下载,速度 有 300 多K,提高了 ...

  2. WINDOWS Server2008上部署Oracle10g及oracle SQL语法小记

    首先安装10G客户端 情况一:一般都会安装到一般报错.因为10G是32BIT客户端.而操作系统是64位的.但是不会影响配置监听程序.自主开发的应用程序依然可以运行. 情况二:报错但是配置完监听程序始终 ...

  3. 关于Windows 7启动后网络一直转的问题的一个解决方法

    前两天给自己的X220i换了个SSD,装了个windows 7 的系统,然后自然搞了一些杀毒软件之类的,为了开发需要还装了Oracle数据库,可是,不知道从什么时候开始,系统启动后右下角那个网络图标显 ...

  4. RESTful Web Services初探

    RESTful Web Services初探 作者:杜刚 近几年,RESTful Web Services渐渐开始流行,大量用于解决异构系统间的通信问题.很多网站和应用提供的API,都是基于RESTf ...

  5. hyper-v虚拟化管理

    一.  什么是Hyper-V? —    Hyper-V是微软的一款虚拟化产品,是微软第一个采用类似Vmware和Citrix开源Xen一样的基于hypervisor的技术. —    Hyper-V ...

  6. shell 脚本,提取文件中的内容

    使用awk.cut.sed.if.while 等 awk.cut.sed还是很重要的 这是后来修改的,可以完成 #!/bin/bash #conver formatFILE=mobile_dpi.ru ...

  7. 金山云—ubuntu-web服务器完整部署笔记

    金山云-ubuntu-web (jdk环境配置+tomcat配置+nginx反向代理)服务器完整部署文档第一步:挂载数据盘 参考金山云帮助文档 http://www.ksyun.com/doc/art ...

  8. 这是个简单的UTF8转码的小Demo

    NSString *name = @"你好啊"; NSString *string = [NSString stringWithFormat:@"%@",nam ...

  9. [Python] MySQLdb(即 MySQL-python 包)在 OS X 中安装指南

    本文参考:http://www.cnblogs.com/ifantastic/archive/2013/04/13/3017677.html 安装环境:OS X 操作系统,Python 2.7.10 ...

  10. iOS 6.0之后支持一个页面横屏的方法

    拿两个页面举例子: 0.开启旋转: 1.第一个界面实现以下方法 /** * 默认显示的方向,preferredInterfaceOrientationForPresentation必须返回一个支持的接 ...