【LeetCode】2. Two Sum】的更多相关文章

[LeetCode]813. Largest Sum of Averages 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/largest-sum-of-averages/description/ 题目描述: We partition a row of numbers A into at most…
[LeetCode]113. Path Sum II 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.me/ 题目地址:https://leetcode.com/problems/path-sum-ii/description/ 题目描述: Given a binary tree and a sum, find all root-to-leaf paths where each…
Difficulty:easy  More:[目录]LeetCode Java实现 Description Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbe…
Difficulty:easy  More:[目录]LeetCode Java实现 Description Design and implement a TwoSum class. It should support the following operations: addand find.add(input) – Add the number input to an internal data structure.find(value) – Find if there exists any…
[Question] Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution. Example: Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + n…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 小根堆 日期 题目地址:https://leetcode.com/problems/maximize-sum-of-array-after-k-negations/ 题目描述 Given an array A of integers, we must modify the array in the following way: we choose a…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 递归 日期 题目地址:https://leetcode.com/contest/weekly-contest-110/problems/range-sum-of-bst/ 题目描述 Given the root node of a binary search tree, return the sum of values of all nodes wi…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 Java解法 Python解法 日期 题目地址:https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/#/description 题目描述 Given an array of integers that is already sorted in ascending order,…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 个人公众号:负雪明烛 本文关键词:two sum, 两数之和,题解,leetcode, 力扣,Python, C++, Java 目录 题目描述 题目大意 解题方法 字典+两次遍历 字典+一次遍历 双指针 日期 题目地址:https://leetcode.com/problems/two-sum/#/description 题目描述 Given an array of integers,…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 DFS + DFS BFS + DFS 日期 题目地址:https://leetcode.com/problems/path-sum-iii/#/description 题目描述 You are given a binary tree in which each node contains an integer value. Find the num…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 预先求和 相似题目 参考资料 日期 题目地址:https://leetcode.com/problems/range-sum-query-2d-immutable/description/ 题目描述 Given a 2D matrix matrix, find the sum of the elements inside the rectangle…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:BFS 方法二:DFS 日期 题目地址:https://leetcode.com/problems/two-sum-iv-input-is-a-bst/description/ 题目描述 Given a Binary Search Tree and a target number, return true if there exist two…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k/description/ 题目描述: Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix su…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays/description/ 题目描述: In a given array nums of positive integers, find three non-overlapping subarrays with maximum su…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 解题方法 保存累积和 日期 题目地址:https://leetcode.com/problems/range-sum-query-immutable/description/ 题目描述 Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), in…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:DFS 方法二:回溯法 日期 题目地址:https://leetcode.com/problems/combination-sum-ii/description/ 题目描述 Given a collection of candidate numbers (candidates) and a target number (target), fi…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.com/problems/subarray-sum-equals-k/description/ 题目描述 Given an array of integers and an integer k, you need to find the total number of continuous subar…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典 前缀树 日期 题目地址:https://leetcode.com/problems/map-sum-pairs/description/ 题目描述 Implement a MapSum class with insert, and sum methods. For the method insert, you'll be given a pai…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.me/ 文章目录 题目描述 题目大意 解题方法 BFS DFS 日期 题目地址:https://leetcode.com/problems/path-sum-ii/description/ 题目描述 Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 动态规划 日期 题目地址:https://leetcode.com/problems/target-sum/description/ 题目描述 You are given a list of non-negative integers, a1, a2, -, an, and a target, S. Now you have 2 symbols +…
Minimum Path Sum Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either down or right at any point in time.   动态规划即可,与Unique…
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either down or right at any point in time. 思路:由于只能向两个方向走,瞬间就没有了路线迂回的烦恼,题目的难度…
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either down or right at any point in time. 思路: 这题不要想得太复杂,什么搜索策略什么贪心什么BFS DFS…
题目描述: Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix such that its sum is no larger than k. 解题思路: 根据题意,寻找二维数组中所有可以组成的矩形中面积不超过k的最大值,所以必须要求出可能组成的矩形的面积并与k比较求出最终结果.这里为了最终不超时,可以在一下方面进行优化: 1.设置一个数组比较当前列(或…
题目: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example:Given the below binary tree and sum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ \ 7 2 1 return…
problem 437. Path Sum III 参考 1. Leetcode_437. Path Sum III; 完…
Combination Sum III Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers. Ensure that numbers within the set are sorted in ascend…
Combination Sum II Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each number in C may only be used once in the combination. Note: All numbers (including t…
Combination Sum Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chosen from C unlimited number of times. Note: All numbers (includi…
Path Sum II Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example:Given the below binary tree and sum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ / \ 7 2 5 1 return [ [5,4,11,2], [5,8,4,5] ] 这题是在Path…