leetcode 1. Two Sum
public class Solution {
public int[] twoSum(int[] nums, int target) {
int[] arr = {0,1};
for(int i = 0;i < nums.length; i++){
for(int j = 0;j< nums.length;j++){
if(nums[i]+nums[j]==target){
arr[0] = i;
arr[1] = j;
return arr;
}
}
}
return arr;
}
leetcode 1. Two Sum相关推荐
- leetcode 304. Range Sum Query 2D - Immutable |304. 二维区域和检索 - 矩阵不可变(二维前缀和问题)
题目 https://leetcode.com/problems/range-sum-query-2d-immutable/ 题解 本题是 medium 难度,二维前缀和问题.相似题目有: Easy: ...
- 【动态规划】LeetCode 377. Combination Sum IV
LeetCode 377. Combination Sum IV Solution1: 我的未能AC的答案 题目描述的和前几道题差不多,但实际上不能用DFS来做(会超时),要用动态规划,还是记录一下吧 ...
- 【DFS】LeetCode 39. Combination Sum
LeetCode 39. Combination Sum Solution1: DFS,这个套路要熟记啊! class Solution { public:vector<vector<in ...
- LeetCode 167.Two Sum II 解题报告
LeetCode 167.Two Sum II 解题报告 题目描述 Given an array of integers that is already sorted in ascending ord ...
- leetcode 1005 Maximize Sum Of Array After K Negations
leetcode 1005 Maximize Sum Of Array After K Negations 1.题目描述 2.解题思路 3.Python代码 1.题目描述 给定一个整数数组 A,我们只 ...
- [勇者闯LeetCode] 1. Two Sum
[勇者闯LeetCode] 1. Two Sum Description Given an array of integers, return indices of the two numbers s ...
- [勇者闯LeetCode] 112. Path Sum
[勇者闯LeetCode] 112. Path Sum Description Given a binary tree and a sum, determine if the tree has a r ...
- 数据结构线段树介绍与笔试算法题-LeetCode 307. Range Sum Query - Mutable--Java解法
此文首发于我的个人博客:zhang0peter的个人博客 LeetCode题解文章分类:LeetCode题解文章集合 LeetCode 所有题目总结:LeetCode 所有题目总结 线段树(Segme ...
- LeetCode 653. Two Sum IV - Input is a BST--Python解法
题目地址:Two Sum IV - Input is a BST - LeetCode Given a Binary Search Tree and a target number, return t ...
- LeetCode 167. Two Sum II - Input array is sorted--Python解法
题目地址:Two Sum II - Input array is sorted - LeetCode Given an array of integers that is already sorted ...
最新文章
- mysql怎么查看是否存在死锁_mysql怎么查看有没有死锁
- 从Openvswitch代码看网络包的旅程
- mysql忘记密码可以卸载吗_mysql忘记密码,修改密码重新安装的一些问题
- 关于Puremvc的理解
- 返回一个二维整数数组中最大子数组的和
- android view超出屏幕_Android APP界面保持屏幕常亮方法
- 把一个英语句子中的单词次序颠倒后输出。例如输入“how are you”,输出“you are how”;...
- 一文读懂开源许可证异同
- postfix报错postfix: fatal: parameter inet_interfaces: no local interface found for ::1
- (翻译).NET应用架构
- 交换机putty怎么调试_弱电工程视频监控系统设计、安装、调试、维护全过程讲解...
- Q窗口操作函数(窗口最大化,全屏,隐藏最大化最小化按钮)
- springboot2源码1-SpringApplication实例化
- 我的linux redhat6.0之路-1.2
- 怎么配置堡垒机_轻量级堡垒机teleport的使用
- HTML5的10大优势
- 怎么下载php文件的电影,下电影下下来是.php格式,请问怎么打开?
- 雷林鹏分享Node.js Buffer(缓冲区)
- 完整的产品管理工作流程
- PLC模拟量控制的3个要求