1 Two Sum
// Java
public int[] twoSum(int[] nums, int target) {
int[] answer = new int[2];
for (int i = 0; i < nums.length; i ++) {
int j = i + 1;
for (; j < nums.length; j ++) {
if (nums[i] + nums[j] == target) {
answer[0] = i;
answer[1] = j;
return answer;
}
}
}
return answer;
}
1 Two Sum的更多相关文章
- LeetCode - Two Sum
Two Sum 題目連結 官網題目說明: 解法: 從給定的一組值內找出第一組兩數相加剛好等於給定的目標值,暴力解很簡單(只會這樣= =),兩個迴圈,只要找到相加的值就跳出. /// <summa ...
- Leetcode 笔记 113 - Path Sum II
题目链接:Path Sum II | LeetCode OJ Given a binary tree and a sum, find all root-to-leaf paths where each ...
- Leetcode 笔记 112 - Path Sum
题目链接:Path Sum | LeetCode OJ Given a binary tree and a sum, determine if the tree has a root-to-leaf ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- BZOJ 3944 Sum
题目链接:Sum 嗯--不要在意--我发这篇博客只是为了保存一下杜教筛的板子的-- 你说你不会杜教筛?有一篇博客写的很好,看完应该就会了-- 这道题就是杜教筛板子题,也没什么好讲的-- 下面贴代码(不 ...
- [LeetCode] Path Sum III 二叉树的路径和之三
You are given a binary tree in which each node contains an integer value. Find the number of paths t ...
- [LeetCode] Partition Equal Subset Sum 相同子集和分割
Given a non-empty array containing only positive integers, find if the array can be partitioned into ...
- [LeetCode] Split Array Largest Sum 分割数组的最大值
Given an array which consists of non-negative integers and an integer m, you can split the array int ...
- [LeetCode] Sum of Left Leaves 左子叶之和
Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two l ...
- [LeetCode] Combination Sum IV 组合之和之四
Given an integer array with all positive numbers and no duplicates, find the number of possible comb ...
随机推荐
- sql2008r 收缩数据库日志log文件;删除errorlog文件的方法
1.清空log文件,以减少数据库文件log所占的空间 USE dbname1 ; GO ALTER DATABASE dbname1 SET RECOVERY SIMPLE;--设置简单恢复模式 GO ...
- C++设计模式-Mediator中介者模式
Mediator中介者模式作用:用一个中介对象来封装一系列的对象交互.中介者使各对象不需要显式地相互引用,从而使其耦合松散,而且可以独立地改变它们之间的交互. UML如下: Colleage抽象同事类 ...
- js判断是否是移动设备登陆网页
var browser = { versions: function () { var u = navigator.userAgent, app = ...
- ajax学习总结
一.ajax简介 AJAX即"Asynchronous Javascript And XML"(异步JavaScript和XML),AJAX 是一种与服务器交换数据的技术,他可以在 ...
- 对于旅游业的手机app的分析
对旅游行业的手机app的测试及分析 随着收入水平的提高,旅游已成为人们的惯常需求.或是为了增长见闻,感悟人生:又或者是愉悦感情,消闷解愁:还有的是为了体验生活,追求情调,同时锻炼身体.当然,旅游的目的 ...
- NHibernate系列文章二十二:NHibernate查询之HQL查询(附程序下载)
摘要 NHibernate提供了多种查询方式,最早的HQL语言查询.Criteria查询和SQL Query,到NHibernate 3.0的Linq NHibernate,NHIbernate 4. ...
- 常见寻找OEP脱壳的方法
方法一: 1.用OD载入,不分析代码! 2.单步向下跟踪F8,是向下跳的让它实现 3.遇到程序往回跳的(包括循环),我们在下一句代码处按F4(或者右健单击代码,选择断点——运行到所选) 4.绿色线条表 ...
- 标识符,unicode和GBK
标识符Identifier 作用: —给变量,类,和方法命名 Java标识符有如下命名规则: —标识符必须以字母,下划线,美元符开头. —标识符其他部分可以是字母,下划线,美元符和数字的任意组合. — ...
- VS2013安装
下载 等待下载完成之后,虽然下载文件是ios格式,但可以用解压缩工具解压打开.解压好后,双击vs_ultimate.exe,开始安装. 自定义选择安装路径,同意许可条款,进行下一步. 在选择安装的可选 ...
- DUBBO参数验证
public class ValidationParameter implements Serializable { private static final long seria ...