[LeetCode] Median of Two Sorted Arrays
来源:互联网 发布:毛笔字软件下载 编辑:程序博客网 时间:2024/05/17 01:40
Median of Two Sorted Arrays
Given an array of integers, find two numbers such that they add up to a specific target number.
The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based.
You may assume that each input would have exactly one solution.
Input: numbers={2, 7, 11, 15}, target=9
Output: index1=1, index2=2
class Solution {public: vector<int> twoSum(vector<int> &numbers, int target) { // Start typing your C/C++ solution below // DO NOT write int main() function int size=numbers.size(); vector<int> ans; if(size<2) return ans; for(int i=0;i<size-1;i++) for(int j=i+1;j<size;j++) { if(numbers[i]+numbers[j]==target) { ans.push_back(i+1); ans.push_back(j+1); return ans; } } }};
- LeetCode: Median of Two Sorted Arrays
- LeetCode Median of Two Sorted Arrays
- leetcode 26: Median of Two Sorted Arrays
- Leetcode 4 Median of Two Sorted Arrays
- [Leetcode] Median of Two Sorted Arrays
- LeetCode 4 - Median of Two Sorted Arrays
- [LeetCode]Median of Two Sorted Arrays
- leetcode Median of Two Sorted Arrays
- LeetCode-Median of Two Sorted Arrays
- [LeetCode] Median of Two Sorted Arrays
- [LeetCode] Median of Two Sorted Arrays
- [leetcode] Median of Two Sorted Arrays
- leetcode-004:Median of Two Sorted Arrays
- Leetcode 4 Median of Two Sorted Arrays
- leetcode之 median of two sorted arrays
- 【转载】【leetcode】Median of Two Sorted Arrays
- LeetCode - Median of Two Sorted Arrays
- [LeetCode]Median of Two Sorted Arrays
- hdu 1856 并查集
- 如何让new 操作 不分配内存 只调用构造函数
- STL
- 微信5.0服务号运营三部曲
- UVA 11198 Dancing Digits (BFS + 判重)
- [LeetCode] Median of Two Sorted Arrays
- Myeclipse中修改Web项目名称后如何在Tomcat中正常运行
- 浅谈HTTP中Get与Post的区别
- 微信5.0改变了哪些游戏规则?
- 读《企业应用架构模式》-锁
- How to Get Neighbors of a Mobile Node in Wireless Simulation
- Zoj 3529 A Game Between Alice and Bob (数学_博弈)
- 可重入函数与不可重入函数
- ivision (DP_斜率优化|四边形不等式优化)