LeetCode Array Easy 1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [, , , ], target = , Because nums[] + nums[] = + = ,
return [, ].
给定一个数组和一个目标,计算数组中任意两个数的和,如果等于目标,则返回这两个数字的下标
C#实现
public class Solution {
    public int[] TwoSum(int[] nums, int target) {
        int[] result = new int[];
            for(int i = ; i< nums.Length - ; i++){
                for(int j = i+; j < nums.Length; j++){
                    if((nums[i] + nums[j]) == target){
                    result[]= i;
                    result[] = j;
                }
            }
        }
        return result;
    }
}

结束
LeetCode Array Easy 1. Two Sum的更多相关文章
- LeetCode Array Easy 167. Two Sum II - Input array is sorted
		Description Given an array of integers that is already sorted in ascending order, find two numbers s ... 
- LeetCode Array Easy 268. Missing Number
		Description Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one th ... 
- LeetCode Array Easy 88. Merge Sorted Array
		Description Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted ar ... 
- LeetCode Array Easy 53. Maximum Subarray 个人解法 和分治思想的学习
		Description Given an integer array nums, find the contiguous subarray (containing at least one numbe ... 
- LeetCode Array Easy 485. Max Consecutive Ones
		Description Given a binary array, find the maximum number of consecutive 1s in this array. Example 1 ... 
- LeetCode Array Easy  448. Find All Numbers Disappeared in an Array
		Description Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear ... 
- LeetCode Array Easy 414. Third Maximum Number
		Description Given a non-empty array of integers, return the third maximum number in this array. If i ... 
- LeetCode Array Easy 283. Move Zeroes
		Description Given an array nums, write a function to move all 0's to the end of it while maintaining ... 
- LeetCode Array Easy 219. Contains Duplicate II
		---恢复内容开始--- Description Given an array of integers and an integer k, find out whether there are two ... 
随机推荐
- maven私服的项目使用配置
			环境: eclipse .maven.nexus. 1.配置setting.xml文件 1.1.配置本地仓库位置:文件中,存在节点 “localRepository”,默认是注释,也就是本地仓库使用 ... 
- shell 脚本学习(一)
			一.vi编辑器的常用指令 1.命令行模式 x #删除一个字符 dd #删除一整行 2.插入模式 i #在光标前插入内容 o #在当前行之下新开一行 3.底行模式 x 或者 wq #保存退出 ... 
- OkHttp的使用
			Download OkHttp3 implementation 'com.squareup.okhttp3:okhttp:3.10.0' 1.1. 异步GET请求 -new OkHttpClient; ... 
- Win7装VS2015报错"安装包丢失或损坏"的解决办法
			在Win7上安装VS2015的过程中,可能会出现下图错误: 这种情况,多半是应为Win7里面缺少了两个证书: Microsoft Root Certificate Authority 2010 Mic ... 
- 第十二章 存储之 Secret
			1.Secret 存在意义 Secret 解决了密码.token.密钥等敏感数据的配置问题,而不需要把这些敏感数据暴露到镜像或者 Pod Spec中.Secret 可以以 Volume 或者环境变量的 ... 
- 配置阿里云SLB全站HTTPS集群
			配置阿里云SLB全站HTTPS集群(以下内容仅为流程,信息可能有些对应不上) 1 登录阿里云购买两台实例 1.1 按量付费购买两台实例 1.2 配置网络可以不选择分配外网 1.3 自定义密码 1.4 ... 
- python问答
			1)什么是Python?使用Python有什么好处? Python是一种编程语言,包含对象,模块,线程,异常和自动内存管理.Python的好处在于它简单易用,可移植,可扩展,内置数据结构,并且它是一个 ... 
- H5 移动调试全攻略
			H5 移动调试全攻略 随着移动设备的高速发展,H5 开发也成为了 F2E 不可或缺的能力.而移动开发的重中之重就是掌握调试技巧,定 Bug于无形. 一.概要 因为移动端操作系统分为 iOS 和 And ... 
- 【leetcode】1005. Maximize Sum Of Array After K Negations
			题目如下: Given an array A of integers, we must modify the array in the following way: we choose an i an ... 
- hdu 5860 Death Sequence(递推+脑洞)
			Problem Description You may heard of the Joseph Problem, the story comes from a Jewish historian liv ... 
