leetcode2sumc-array_leetcode:leetcode刷题总结,此部分是array

时间:2021-06-30 17:49:32
【文件属性】:
文件名称:leetcode2sumc-array_leetcode:leetcode刷题总结,此部分是array
文件大小:5KB
文件格式:ZIP
更新时间:2021-06-30 17:49:32
系统开源 leetcode 2 sum c array_leetcode leetcode刷题总结,此部分是array #第一题 问题: Given an array of integers, return indices of the two numbers such that they add up to a specific target. 程序: #include using namespace std; class Solution { public: vector twoSum(vector& nums, int target) { vector index; for(int i=0;i<nums.size();i++) { for(int j=i+1;j<nums.size();j++) { if(nums[i]+nums[j]==target) { index.push_back(i);index.push_back(j); return index; } } } } }; #第二题 问题: There are two sorted arrays nums1 and nums2
【文件预览】:
array_leetcode-master
----README.md(10KB)

网友评论