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 ...
随机推荐
- delphi.指针.应用
注:初稿...有点乱,可能增删改... 因为指针应用,感觉不好写,请大家指出错误,谢谢. 注意: 本文着重点讲的是指针的各类型的应用或使用,而不是说这种方法不应该+不安全+危险+不提倡使用. 其它:本 ...
- 【转载】变更MySql数据存储路径的方法
1.在mysql安装目录下找到my.ini文件,更改#Path to the database root datadir="希望存放数据的地址" 2.将默认存放路径(一般为&quo ...
- C++设计模式-Proxy代理模式
Proxy代理模式 作用:为其他对象提供一种代理以控制对这个对象的访问. 代理的种类: 如果按照使用目的来划分,代理有以下几种: 远程(Remote)代理:为一个位于不同的地址空间的对象提供一个局域代 ...
- Geodatabase数据模型
1 Geodatabase概念 Geodatabase是ArcInfo8引入的一种全新的面向对象的空间数据模型,是建立在DBMS之上的统一的.智能的空间数据模型.“统一”是指,Geodatabase ...
- 关于C#本质论和CLR via C#中译本,不吐不快
C#本质论和CLR via C#两本好书,周老师可能是俗务缠身,太忙了吧,翻译得只能让人呵呵了. 你要是忙,别接那么多活好不啦. 现在都在说供给侧改革,都在大力提倡工匠精神,我们做技术的,还是踏实点好 ...
- MSSQL 跨数据库连接
SELECT * FROM opendatasource('sqloledb','data source=192.168.1.197;user id=sa;password=sa').SafetyMo ...
- 嵌入式: jffs2,yaffs2,logfs,ubifs文件系统性能分析
在嵌入式领域,FLASH是一种常用的存储介质,由于其特殊的硬件结构,所以普通的文件系统如ext2,ext3等都不适合在其上使用,于是就出现了专门针对FLASH的文件系统,比较常用的有jffs2,yaf ...
- Theme皮肤文件(json解析、多文件管理)
一 官方教程 http://developer.egret.com/cn/github/egret-docs/extension/EUI/skin/theme/index.html 二 thm主题文 ...
- java后端书籍推荐
书架主要针对Java后端开发. 3.0版把一些后来买的.看的书添补进来,又或删掉或降级一些后来没有再翻开过的书. 更偏爱那些能用简短流畅的话,把少壮不努力的程序员所需的基础补回来的薄书,而有些教课书可 ...
- PHP连接MySQL的时候报错SQLSTATE[HY000] [2002] No such file or directory
错误环境:Mac OS 10.10 找到mysql.sock文件的位置 $sudo find / -name mysql.sock ------结果如下---------- find: /dev/fd ...