"【简单】1 两数之和 Two Sum" "【中等】2 两数相加 Add Two Num" "【中等】3 无重复字符的最长子串 Longest Substring Without Repeating Characters" "【困难】4 寻找两个有序数组的中位数 Median of Two Sort ...
分类:
其他好文 时间:
2020-04-15 15:15:11
阅读次数:
70
题意:在BST中寻找两个节点,使它们的和为一个给定值。 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(in ...
分类:
其他好文 时间:
2020-03-26 01:22:25
阅读次数:
70
地址:https://leetcode-cn.com/problems/two-sum/ <?php /** * Created by PhpStorm. * User: huahua * Date: 2020/3/18 * Time: 下午6:23 */ /** * 给定一个整数数组 nums 和 ...
分类:
其他好文 时间:
2020-03-19 09:35:48
阅读次数:
69
来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/two-sum 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是,你不能重复利用 ...
分类:
其他好文 时间:
2020-03-17 14:03:15
阅读次数:
47
基本原理就不做介绍了, 很基础的数据结构课程知识.私下回顾即可,主要学习代码. 1.双指针 https://leetcode-cn.com/problems/two-sum-ii-input-array-is-sorted/description/?utm_source=LCUS&utm_mediu ...
分类:
编程语言 时间:
2020-03-15 13:20:39
阅读次数:
70
1 class Solution { 2 public int[] twoSum(int[] nums, int target) { 3 Map<Integer, Integer> map = new HashMap<>(); 4 for (int i = 0; i < nums.length; i ...
分类:
编程语言 时间:
2020-03-12 14:41:34
阅读次数:
64
[剑指Offer]41 和为S的两个数字 VS 和为S的连续正数序列 Leetcode T1 Two Sum Given an array of integers, return indices of the two numbers such that they add up to a specif ...
分类:
其他好文 时间:
2020-03-06 12:41:24
阅读次数:
59
Design and implement a TwoSum class. It should support the following operations: add and find. add - Add the number to an internal data structure.find ...
分类:
其他好文 时间:
2020-03-04 09:16:12
阅读次数:
75
LeetCode 0167: Two Sum II Input array is sorted【Python】 题目 "英文题目链接" Given an array of integers that is already sorted in ascending order\ , find two n ...
分类:
编程语言 时间:
2020-02-12 00:19:27
阅读次数:
74
Two Sum类 首先是基本的Two Sum题解 用hashmap 时间复杂度O(n),空间复杂度O(n),每一次首先找hashmap中有没有target - nums[i], 如果没有将nums[i]入map 用双指针法,时间复杂度O(n + nlogn), 空间复杂度O(1) 首先要对数组进行排 ...
分类:
其他好文 时间:
2020-02-11 09:28:14
阅读次数:
43