![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
Ber03
:)
展开
-
[LeetCode] HashMap题目总结
1. Two Sum找出数组中加起来等于target的两个数。每一个输入有且仅有一个解,但是同一个元素不能使用两次。可以使用HashMap + 单遍循环,key为数组中的元素,value为下标。如果hashmap中已经存储过target - nums[i]了,那么就找到了一对结果。如果没有存储过target - nums[i],那么就将(nums[i] , i)放入HashMap。class...原创 2019-12-15 16:50:02 · 748 阅读 · 0 评论 -
[LeetCode] 118. Pascal's Triangle
原题链接:https://leetcode.com/problems/pascals-triangle/1. 题目介绍Given a non-negative integer numRows, generate the first numRows of Pascal’s triangle.In Pascal’s triangle, each number is the sum of the...原创 2019-12-01 00:05:56 · 198 阅读 · 0 评论 -
[LeetCode] 1. Two Sum
Two Sum原题链接: https://leetcode.com/problems/two-sum/1. 题目描述Leetcode 第一题输入:一组整数数组,和一个target值。输出:两个整数加起来如果等于target,输出这两个整数的下标每个输入都会有一个解,同一次输入不会有相同的整数。Example:Given nums = [2, 7, 11, 15], target =...原创 2019-02-03 00:15:28 · 159 阅读 · 0 评论 -
[LeetCode] 15. 3Sum
原题链接: https://leetcode.com/problems/3sum/1. 题目描述2. 解题思路Java中List的用法List是一个有序的集合,允许存储项的值为空,也允许相等值的存储项。List<String> ex=new ArrayList<>();原创 2019-02-03 22:05:45 · 142 阅读 · 0 评论 -
[LeetCode] 446. Arithmetic Slices II - Subsequence
原题链接: https://leetcode.com/problems/arithmetic-slices-ii-subsequence/相关题目:413. Arithmetic Slices1. 题目介绍A sequence of numbers is called arithmetic if it consists of at least three elements and if th...原创 2019-02-14 23:29:34 · 288 阅读 · 0 评论 -
[LeetCode] 18. 4Sum
原题链接: https://leetcode.com/problems/4sum/1. 题目描述Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = targetFind all unique qu...原创 2019-02-03 23:33:03 · 135 阅读 · 0 评论 -
[LeetCode] 16. 3Sum Closest
原题链接: https://leetcode.com/problems/3sum-closest/1. 题目描述Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of...原创 2019-02-04 14:25:45 · 134 阅读 · 0 评论 -
[LeetCode] 167. Two Sum II - Input array is sorted
原题链接: https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/1. 题目描述Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific...原创 2019-02-04 17:23:31 · 165 阅读 · 0 评论 -
[LeetCode] 653. Two Sum IV - Input is a BST
原题链接: https://leetcode.com/problems/two-sum-iv-input-is-a-bst/题目描述Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to t...原创 2019-02-05 20:06:34 · 226 阅读 · 0 评论 -
[LeetCode] 560. Subarray Sum Equals K
原题链接: https://leetcode.com/problems/subarray-sum-equals-k/1.题目描述Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.Example ...原创 2019-02-09 00:24:01 · 149 阅读 · 0 评论 -
[LeetCode] 123. Best Time to Buy and Sell Stock III
原题链接:https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/1. 题目简介Say you have an array for which the i th element is the price of a given stock on day i.Design an algorithm to find the...原创 2019-02-16 21:47:35 · 185 阅读 · 0 评论 -
[LeetCode] 53. Maximum Subarray
原题链接: https://leetcode.com/problems/maximum-subarray/1. 题目描述Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.E...原创 2019-02-08 18:24:38 · 98 阅读 · 0 评论 -
[LeetCode] 121. Best Time to Buy and Sell Stock
原题链接: https://leetcode.com/problems/best-time-to-buy-and-sell-stock/1. 题目介绍Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to compl...原创 2019-02-09 17:30:54 · 170 阅读 · 0 评论 -
[LeetCode] 122. Best Time to Buy and Sell Stock II
原题链接: https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/1. 题目描述Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the ...原创 2019-02-09 19:20:02 · 139 阅读 · 0 评论 -
[LeetCode] 371. Sum of Two Integers
原题链接: https://leetcode.com/problems/sum-of-two-integers/1. 题目介绍Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example 1:Input: a = 1, b = 2Output:...原创 2019-02-09 22:09:12 · 186 阅读 · 0 评论 -
[LeetCode] 188. Best Time to Buy and Sell Stock IV
原题链接: https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/Buy and Sell Stock专题相关题目121. Best Time to Buy and Sell Stock122. Best Time to Buy and Sell Stock II123. Best Time to Buy and ...原创 2019-02-16 23:30:04 · 146 阅读 · 0 评论 -
[LeetCode] 337. House Robber III
原题链接: https://leetcode.com/problems/house-robber-iii/House Robber 专题相关题目198. House Robber213. House Robber II[337. House Robber III]1. 题目介绍The thief has found himself a new place for his thiever...原创 2019-02-22 18:33:06 · 239 阅读 · 0 评论 -
[LeetCode] 62. Unique Paths
原题链接: https://leetcode.com/problems/unique-paths/1. 题目介绍A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right ...原创 2019-02-22 22:43:22 · 139 阅读 · 0 评论 -
[LeetCode] 650. 2 Keys Keyboard
原题链接: https://leetcode.com/problems/2-keys-keyboard/1. 题目描述Initially on a notepad only one character ‘A’ is present. You can perform two operations on this notepad for each step:Copy All: You can c...原创 2019-02-11 23:28:29 · 144 阅读 · 0 评论 -
[LeetCode] 309. Best Time to Buy and Sell Stock with Cooldown
原题链接: https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/Buy and Sell Stock相关题目1. 题目简介Say you have an array for which the ith element is the price of a given stock on day i...原创 2019-02-17 22:37:38 · 143 阅读 · 0 评论 -
[LeetCode] 714. Best Time to Buy and Sell Stock with Transaction Fee
原题链接:https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/Buy and Sell Stock专题相关题目121. Best Time to Buy and Sell Stock122. Best Time to Buy and Sell Stock II123. Best...原创 2019-02-17 23:34:36 · 152 阅读 · 0 评论 -
[LeetCode] 63. Unique Paths II
原题链接: https://leetcode.com/problems/unique-paths-ii/1. 题目介绍A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or rig...原创 2019-02-23 00:05:14 · 136 阅读 · 0 评论 -
[LeetCode] 70. Climbing Stairs
原题链接: https://leetcode.com/problems/climbing-stairs/1. 题目描述You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways...原创 2019-02-23 10:20:06 · 102 阅读 · 0 评论 -
[LeetCode] 746. Min Cost Climbing Stairs
原题链接: https://leetcode.com/problems/min-cost-climbing-stairs/Climbing Stairs专题相关题目70. Climbing Stairs746. Min Cost Climbing Stairs1. 题目介绍On a staircase, the i-th step has some non-negative cost c...原创 2019-02-23 10:57:34 · 120 阅读 · 0 评论 -
[LeetCode] 413. Arithmetic Slices
原题链接: https://leetcode.com/problems/arithmetic-slices/1. 题目介绍A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive ele...原创 2019-02-12 21:12:21 · 162 阅读 · 0 评论 -
[LeetCode] 55. Jump Game
原题链接:https://leetcode.com/problems/jump-game/1. 题目介绍Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your m...原创 2019-02-23 22:23:51 · 113 阅读 · 0 评论 -
[LeetCode] 5. Longest Palindromic Substring
原题链接: https://leetcode.com/problems/longest-palindromic-substring/3. 参考资料https://leetcode.com/problems/longest-palindromic-substring/discuss/2921/Share-my-Java-solution-using-dynamic-programming...原创 2019-02-13 13:26:42 · 120 阅读 · 0 评论 -
[LeetCode] 91. Decode Ways
原题链接:https://leetcode.com/problems/decode-ways/1. 题目介绍A message containing letters from A-Z is being encoded to numbers using the following mapping:‘A’ -> 1‘B’ -> 2…‘Z’ -> 26Given a no...原创 2019-02-25 14:00:46 · 111 阅读 · 0 评论 -
[LeetCode] 198. House Robber
原题链接: https://leetcode.com/problems/house-robber/1. 题目介绍You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint sto...原创 2019-02-19 21:54:40 · 125 阅读 · 0 评论 -
[LeetCode] 312. Burst Balloons
原题链接:https://leetcode.com/problems/burst-balloons/1. 题目介绍Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all th...原创 2019-03-05 00:49:30 · 185 阅读 · 0 评论 -
[LeetCode] 213. House Robber II
原题链接: https://leetcode.com/problems/house-robber-ii/House Robber 专题相关题目198. House Robber1. 题目介绍You are a professional robber planning to rob houses along a street. Each house has a certain amount ...原创 2019-02-22 16:08:52 · 199 阅读 · 0 评论 -
[LeetCode] 395. Longest Substring with At Least K Repeating Characters
原题链接: https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/1. 题目介绍Find the length of the longest substring T of a given string (consists of lowercase letters only) su...原创 2019-03-05 17:34:31 · 123 阅读 · 0 评论 -
[LeetCode] 258. Add Digits
原题链接: https://leetcode.com/problems/add-digits/1. 题目介绍Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.Follow up:Could you do it without any loop...原创 2019-03-06 11:22:22 · 125 阅读 · 0 评论 -
[LeetCode] 898. Bitwise ORs of Subarrays
原题链接: https://leetcode.com/problems/bitwise-ors-of-subarrays/1. 题目介绍We have an array A of non-negative integers.For every (contiguous) subarray B = [A[i], A[i+1], …, A[j]] (with i <= j), we take...原创 2019-03-02 17:52:46 · 266 阅读 · 0 评论 -
[LeetCode] 96. Unique Binary Search Trees
原题链接: https://leetcode.com/problems/unique-binary-search-trees/1. 题目介绍Given n, how many structurally unique BST’s (binary search trees) that store values 1 … n?给出一个数n,求从1到n的所有数可以形成多少种不一样的二叉树?Examp...原创 2019-03-03 13:32:35 · 169 阅读 · 0 评论 -
[LeetCode] 202. Happy Number
原题链接: https://leetcode.com/problems/happy-number/1. 题目介绍Write an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positiv...原创 2019-03-06 15:27:11 · 148 阅读 · 0 评论 -
[LeetCode] 303. Range Sum Query - Immutable
原题链接: https://leetcode.com/problems/range-sum-query-immutable/1. 题目介绍Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, ...原创 2019-03-15 01:01:31 · 112 阅读 · 0 评论 -
[LeetCode] 717. 1-bit and 2-bit Characters
原题链接: https://leetcode.com/problems/1-bit-and-2-bit-characters/1. 题目介绍实现代码class Solution { public boolean isOneBitCharacter(int[] bits) { int length = bits.length; if(length ==0...原创 2019-03-14 23:41:15 · 105 阅读 · 0 评论 -
[LeetCode] 304. Range Sum Query 2D - Immutable
原题链接: https://leetcode.com/problems/range-sum-query-2d-immutable/1. 题目介绍Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and ...原创 2019-03-15 00:58:03 · 124 阅读 · 0 评论 -
[LeetCode] 120. Triangle
原题链接: https://leetcode.com/problems/triangle/1. 题目介绍Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given th...原创 2019-03-07 22:30:52 · 103 阅读 · 0 评论