leetcode
importsys
zjuer
展开
-
leetcode 458. Poor Pigs详解
458. Poor Pigsdescription:There are 1000 buckets, one and only one of them is poisonous, while the rest are filled with water. They all look identical. If a pig drinks the poison it will die within ...原创 2019-05-25 22:35:09 · 651 阅读 · 0 评论 -
LeetCode 435. Non-overlapping Intervals 无重叠区间(贪心问题,两种解法)
LeetCode 435. Non-overlapping Intervals 无重叠区间435. Non-overlapping Intervals 无重叠区间题目描述示例:解答1代码1解答1代码1435. Non-overlapping Intervals 无重叠区间题目描述Given a collection of intervals, find the minimum number ...原创 2019-06-14 17:31:43 · 403 阅读 · 0 评论 -
Leetcode 322. Coin Change 零钱兑换
Leetcode 322. Coin Change 零钱兑换322. Coin Change题目描述示例:解答代码322. Coin Change题目描述You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewes...原创 2019-06-09 21:00:42 · 192 阅读 · 0 评论 -
Leetcode 518. Coin Change 2 零钱兑换2
Leetcode 518. Coin Change 2 零钱兑换2322. Coin Change题目描述示例:解答代码322. Coin Change题目描述You are given coins of different denominations and a total amount of money. Write a function to compute the number of...原创 2019-06-09 21:06:28 · 243 阅读 · 0 评论 -
LeetCode 726. Number of Atoms 原子的数量
LeetCode 726. Number of Atoms 原子的数量726. Number of Atoms 原子的数量题目描述示例:解答代码726. Number of Atoms 原子的数量题目描述Given a chemical formula (given as a string), return the count of each atom.An atomic element ...原创 2019-06-03 21:23:22 · 199 阅读 · 0 评论 -
Leetcode 72. Edit Distance 编辑距离
Leetcode 72. Edit Distance 编辑距离72. Edit Distance 编辑距离题目描述示例:解答代码72. Edit Distance 编辑距离题目描述Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2....原创 2019-06-10 18:00:01 · 391 阅读 · 0 评论 -
Leetcode 70. Climbing Stairs 爬楼梯
Leetcode 70. Climbing Stairs 爬楼梯70. Climbing Stairs 爬楼梯题目描述示例:解答代码70. Climbing Stairs 爬楼梯题目描述You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or...原创 2019-06-10 18:05:31 · 227 阅读 · 0 评论 -
LeetCode 139. Word Break 单词拆分
Leetcode 139. Word Break 单词拆分139. Word Break 单词拆分题目描述示例:解答1代码1解答2代码2139. Word Break 单词拆分题目描述Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s...原创 2019-06-04 20:24:39 · 222 阅读 · 0 评论 -
LeetCode 303. Range Sum Query - Immutable 区域和检索 - 数组不可变
LeetCode 303. Range Sum Query - Immutable 区域和检索 - 数组不可变303. Range Sum Query - Immutable题目描述示例:解答代码303. Range Sum Query - Immutable题目描述Given an integer array nums, find the sum of the elements betwe...原创 2019-06-04 21:48:22 · 173 阅读 · 0 评论 -
LeetCode 698. Partition to K Equal Sum Subsets 划分为k个相等的子集(典型递归问题)
LeetCode 698. Partition to K Equal Sum Subsets 划分为k个相等的子集:典型递归问题698. Partition to K Equal Sum Subsets 划分为k个相等的子集题目描述示例:解答代码698. Partition to K Equal Sum Subsets 划分为k个相等的子集题目描述Given an array of inte...原创 2019-06-18 15:26:54 · 268 阅读 · 0 评论 -
Leetcode 202. Happy Number 快乐数
Leetcode 202. Happy Number 快乐数202. Happy Number 快乐数题目描述示例:解答1代码1解答2代码2202. Happy Number 快乐数题目描述ShareWrite an algorithm to determine if a number is “happy”.A happy number is a number defined by th...原创 2019-06-18 15:45:58 · 446 阅读 · 0 评论 -
Leetcode 878. Nth Magical Number 第 N 个神奇数字(二分查找)
Leetcode 878. Nth Magical Number 第 N 个神奇数字878. Nth Magical Number 第 N 个神奇数字题目描述示例:解答代码878. Nth Magical Number 第 N 个神奇数字题目描述A positive integer is magical if it is divisible by either A or B.Return ...原创 2019-06-18 17:32:26 · 384 阅读 · 0 评论 -
Leetcode 692. Top K Frequent Words 前K个高频单词(最小堆)
Leetcode 692. Top K Frequent Words 前K个高频单词:最小堆692. Top K Frequent Words 前K个高频单词题目描述示例:解答代码692. Top K Frequent Words 前K个高频单词题目描述Given a non-empty list of words, return the k most frequent elements....原创 2019-06-18 17:41:22 · 429 阅读 · 0 评论 -
LeetCode 898. Bitwise ORs of Subarrays 子数组按位或操作
LeetCode 898. Bitwise ORs of Subarrays 子数组按位或操作898. Bitwise ORs of Subarrays题目描述示例:解答代码898. Bitwise ORs of Subarrays题目描述We have an array A of non-negative integers.For every (contiguous) subarray ...原创 2019-07-07 10:13:12 · 496 阅读 · 0 评论 -
Leetcode 784. Letter Case Permutation 字母大小写全排列
Leetcode 784. Letter Case Permutation 字母大小写全排列Leetcode 784. Letter Case Permutation 字母大小写全排列题目描述示例:解答代码Leetcode 784. Letter Case Permutation 字母大小写全排列题目描述Given a string S, we can transform every let...原创 2019-08-04 10:27:52 · 173 阅读 · 0 评论 -
Leetcode 524. Longest Word in Dictionary through Deleting 通过删除字母匹配到字典里最长单词
Leetcode 524. Longest Word in Dictionary through Deleting 通过删除字母匹配到字典里最长单词524. Longest Word in Dictionary through Deleting题目描述示例:解答代码524. Longest Word in Dictionary through Deleting题目描述Given a stri...原创 2019-08-04 10:30:35 · 144 阅读 · 0 评论 -
Leetcode 28. Implement strStr() 实现 strStr()
@[TOC](Leetcode 28. Implement strStr() 实现 strStr())28. Implement strStr()题目描述Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of hayst...原创 2019-08-04 14:24:21 · 188 阅读 · 0 评论 -
LeetCode 452. Minimum Number of Arrows to Burst Balloons 用最少数量的箭引爆气球(贪心问题)
LeetCode 452. Minimum Number of Arrows to Burst Balloons 用最少数量的箭引爆气球452. Minimum Number of Arrows to Burst Balloons 用最少数量的箭引爆气球Description:Example:解答代码452. Minimum Number of Arrows to Burst Balloons ...原创 2019-06-14 16:54:02 · 305 阅读 · 0 评论 -
Leetcode 82. Remove Duplicates from Sorted List II 删除排序链表中的重复元素 II
Leetcode 82. Remove Duplicates from Sorted List II 删除排序链表中的重复元素 II1. Two Sum题目描述示例:解答1代码1解答2代码21. Two Sum题目描述Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only d...原创 2019-06-02 20:15:38 · 297 阅读 · 0 评论 -
leetcode 4. Median of Two Sorted Arrays详解
4. Median of Two Sorted Arraysdescription:There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should b...原创 2019-05-26 17:48:16 · 228 阅读 · 0 评论 -
leetcode 871. Minimum Number of Refueling Stops详解
871. Minimum Number of Refueling Stopsdescription:TA car travels from a starting position to a destination which is target miles east of the starting position.Along the way, there are gas stations....原创 2019-05-26 21:05:15 · 428 阅读 · 0 评论 -
Leetcode K-th Smallest in Lexicographical Order详解
440. K-th Smallest in Lexicographical OrderDescription:Given integers n and k, find the lexicographically k-th smallest integer in the range from 1 to n.Note: 1 ≤ k ≤ n ≤ 109.Example:Input:n: 13...原创 2019-05-27 19:24:29 · 510 阅读 · 0 评论 -
Leetcode 1. Two Sum 两数之和
Leetcode 1. Two Sum1. Two Sum题目描述示例:解答代码1. Two Sum题目描述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 ...原创 2019-05-30 19:28:55 · 217 阅读 · 0 评论 -
Leetcode 15. 3Sum 三数之和
Leetcode 15. 3Sum15. 3Sum题目描述示例:解答代码15. 3Sum题目描述Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the ...原创 2019-05-30 19:37:38 · 158 阅读 · 0 评论 -
Leetcode 394. Decode String 字符串解码
Leetcode 394. Decode String394. Decode String题目描述示例:解答代码394. Decode String题目描述Given an encoded string, return it’s decoded string.The encoding rule is: k[encoded_string], where the encoded_string ...原创 2019-05-30 19:57:40 · 242 阅读 · 0 评论 -
LeetCode 300. Longest Increasing Subsequence 最长上升子序列
LeetCode 300. Longest Increasing Subsequence 最长上升子序列300. Longest Increasing Subsequence题目描述示例:解答代码解法1解法2300. Longest Increasing Subsequence题目描述Given an unsorted array of integers, find the length o...原创 2019-05-31 17:05:08 · 243 阅读 · 0 评论 -
LeetCode 354. Russian Doll Envelopes 俄罗斯套娃信封问题
LeetCode 354. Russian Doll Envelopes 俄罗斯套娃信封问题354. Russian Doll Envelopes题目描述示例:解答代码解法1解法2354. Russian Doll Envelopes题目描述You have a number of envelopes with widths and heights given as a pair of in...原创 2019-05-31 17:13:31 · 356 阅读 · 5 评论 -
Leetcode 11. Container With Most Water题解
4. Median of Two Sorted ArraysDescriptionGiven n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of ...原创 2019-05-28 20:59:52 · 266 阅读 · 0 评论 -
LeetCode 112. Path Sum 路径总和
Leetcode 112. Path Sum 路径总和112. Path Sum 路径总和题目描述示例:解答1代码1解答2代码2112. Path Sum 路径总和题目描述Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values...原创 2019-06-05 21:45:50 · 146 阅读 · 0 评论 -
LeetCode 198. House Robber 打家劫舍
LeetCode 198. House Robber 打家劫舍198. House Robber题目描述示例:解答代码198. House Robber题目描述You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed...原创 2019-06-06 00:15:23 · 189 阅读 · 0 评论 -
Leetcode 946. Validate Stack Sequences 验证栈序列
Leetcode 946. Validate Stack Sequences 验证栈序列946. Validate Stack Sequences题目描述示例示例1示例2解答946. Validate Stack Sequences题目描述Given two sequences pushed and popped with distinct values, return true if an...原创 2019-05-31 22:46:50 · 201 阅读 · 0 评论 -
Leetcode 1011. Capacity To Ship Packages Within D Days 在 D 天内送达包裹的能力
Leetcode 1011. Capacity To Ship Packages Within D Days 在 D 天内送达包裹的能力1011. Capacity To Ship Packages Within D Days题目描述:示例:解答:代码:1011. Capacity To Ship Packages Within D Days题目描述:A conveyor belt has ...原创 2019-05-31 23:33:24 · 230 阅读 · 0 评论 -
Leetcode 855. Exam Room 考场就座:提供两种解法
Leetcode 855. Exam Room 考场就座: 提供两种解法855. Exam Room 考场就座(两种解法)题目描述示例:解答1代码1解答2代码2855. Exam Room 考场就座(两种解法)题目描述In an exam room, there are N seats in a single row, numbered 0, 1, 2, …, N-1.When a stu...原创 2019-06-13 15:35:44 · 565 阅读 · 0 评论 -
Leetcode 96. Unique Binary Search Trees 不同的二叉搜索树: 两种思路
Leetcode 96. Unique Binary Search Trees 不同的二叉搜索树: 两种思路96. Unique Binary Search Trees 不同的二叉搜索树题目描述示例:解答代码96. Unique Binary Search Trees 不同的二叉搜索树题目描述Given n, how many structurally unique BST’s (binar...原创 2019-06-13 15:51:24 · 320 阅读 · 0 评论 -
Leetcode 83. Remove Duplicates from Sorted List 删除排序链表中的重复元素
Leetcode 83. Remove Duplicates from Sorted List 删除排序链表中的重复元素1. Two Sum题目描述示例:解答1代码1解答2代码21. Two Sum题目描述Given a sorted linked list, delete all duplicates such that each element appear only once.示例:...原创 2019-06-02 20:13:32 · 249 阅读 · 0 评论 -
Leetcode 28. Implement strStr() 实现 strStr()
@[TOC](Leetcode 28. Implement strStr() 实现 strStr())28. Implement strStr()题目描述Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of hayst...原创 2019-08-04 14:24:59 · 183 阅读 · 0 评论