【LeetCode】(C#)1. Two Sum(Easy)
2017-12-27 11:17
351 查看
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.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
public int[] TwoSum(int[] nums, int target) { int[] result=new int[2]; for(int i=0;i<nums.Length;i++) { for(int j=0;j<nums.Length;j++) { if(i!=j) { if(nums[i]+nums[j]==target) return new int [] {i,j}; } } } return result; }
相关文章推荐
- LeetCode (Easy Part) Two Sum
- 【Leetcode】Two sum(easy)
- LeetCode 1. Two Sum (Easy)
- LeetCode解题报告 1. Two Sum[easy]
- 蜗牛慢慢爬 LeetCode 1.Two Sum [Difficulty: Easy]
- LeetCode第一关:Two Sum --> Difficulty: Easy
- leetcode1--two sum(easy)
- Leetcode解题笔记 1.Two Sum [Easy]
- Leetcode 1. Two Sum (Easy) (cpp)
- 算法分析与设计——LeetCode刷题之TwoSum(easy)
- leetcode 1:TwoSum (C#语言版)
- leetcode 167[easy]---Two Sum II - Input array is sorted
- leetcode——TwoSum(c#)
- Leetcode 1. Two Sum (Easy) (java)
- 【leetcode】Two Sum (easy)
- LeetCode 第1题 Two sum (easy)——python
- 【Leetcode】Two Sum II #Too easy, just review hashmap
- LeetCode-Easy刷题(6) Merge Two Sorted Lists
- leetcode之Two Sum问题
- leetcode : Add Two Sum