![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
Mereder
这个作者很懒,什么都没留下…
展开
-
Leetcode 1 TwoSum -Java刷题
Java hashmap的用法 类似于Python 里面的 dict 字典 先将 数组 进行 hashmap hash过程是O(N)的 再从 hashmap中寻找 目标值和另一个加数的差值 如果找到 且 index != i 则说明存在 TwoSum 算法复杂度 为O(n) three sum 的问题 也是 类似这样求解,先对一个加数使用Hash 然后循环遍历另外两个加数 复杂度 降低到...原创 2019-04-03 21:39:00 · 130 阅读 · 0 评论 -
Leetcode刷题 二分查找总结-Java
正常版本 /** * 二分查找,找到该值在数组中的下标,否则为-1 */ public static int binarySerach(int[] array, int key) { int left = 0; int right = array.length - 1; // 这里必须是 <= while (left <= right) { ...原创 2019-04-03 21:43:00 · 521 阅读 · 0 评论