杨领well的 LeetCode 题解专栏
文章平均质量分 73
极客挚爱的高质量在线技术平台,想要学习和提升专业能力从这里开始,充足技术干货等你来啃,轻松拿下 Dream Offer!
本栏目定期更新 LeetCode 题解。
杨领well
君子食无求饱,居无求安,敏于事而慎于言,就有道而正焉。
展开
-
LeetCode: 335. Self Crossing
LeetCode: 335. Self Crossing题目描述You are given an array x of n positive numbers. You start at point (0,0) and moves x[0] metres to the north, then x[1] metres to the west, x[2] metres to the south, x...原创 2019-12-02 09:23:33 · 218 阅读 · 0 评论 -
LeetCode: 334. Increasing Triplet Subsequence
LeetCode: 334. Increasing Triplet Subsequence题目描述Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.Formally the function should:Return true if...原创 2019-11-27 09:18:26 · 140 阅读 · 0 评论 -
LeetCode: 332. Reconstruct Itinerary
LeetCode: 332. Reconstruct Itinerary题目描述Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belo...原创 2019-11-26 09:20:35 · 248 阅读 · 0 评论 -
LeetCode: 331. Verify Preorder Serialization of a Binary Tree
LeetCode: 331. Verify Preorder Serialization of a Binary Tree题目描述One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node’s value. If i...原创 2019-11-25 08:22:20 · 176 阅读 · 0 评论 -
LeetCode: 330. Patching Array
LeetCode: 330. Patching Array题目描述Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be formed by the sum ...原创 2019-11-24 17:28:09 · 207 阅读 · 0 评论 -
LeetCode: 329. Longest Increasing Path in a Matrix
LeetCode: 329. Longest Increasing Path in a Matrix题目描述Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up...原创 2019-11-22 09:32:47 · 189 阅读 · 0 评论 -
LeetCode: 328. Odd Even Linked List
LeetCode: 328. Odd Even Linked List题目描述Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in...原创 2019-11-21 08:16:16 · 166 阅读 · 0 评论 -
LeetCode: 327. Count of Range Sum
LeetCode: 327. Count of Range SumGiven an integer array nums, return the number of range sums that lie in [lower, upper] inclusive.Range sum S(i, j) is defined as the sum of the elements in nums bet...原创 2019-11-19 08:37:39 · 209 阅读 · 0 评论 -
LeetCode:324. Wiggle Sort II
LeetCode:324. Wiggle Sort II题目描述Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]…Example 1:Input: nums = [1, 5, 1, 1, 6, 4]Output: One possible an...原创 2019-11-17 08:12:13 · 165 阅读 · 0 评论 -
LeetCode: 322. Coin Change
LeetCode: 322. Coin Change题目描述You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that ...原创 2019-11-13 08:08:10 · 142 阅读 · 0 评论 -
LeetCode: 321. Create Maximum Number
LeetCode: 321. Create Maximum Number题目描述Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. The rel...原创 2019-11-12 08:46:08 · 193 阅读 · 0 评论 -
LeetCode: 318. Maximum Product of Word Lengths
LeetCode: 318. Maximum Product of Word Lengths题目描述Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may ass...原创 2019-11-09 10:03:42 · 151 阅读 · 0 评论 -
LeetCode: 319. Bulb Switcher
[LeetCode: 319. Bulb Switcher](LeetCode: 319. Bulb Switcher)题目描述There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, y...原创 2019-11-10 19:41:59 · 195 阅读 · 0 评论 -
LeetCode: 316. Remove Duplicate Letters
LeetCode: 316. Remove Duplicate Letters题目描述Given a string which contains only lowercase letters, remove duplicate letters so that every letter appears once and only once. You must make sure your res...原创 2019-11-08 09:31:10 · 185 阅读 · 0 评论 -
LeetCode: 315. Count of Smaller Numbers After Self
LeetCode: 315. Count of Smaller Numbers After Self题目描述You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number o...原创 2019-11-07 07:45:41 · 166 阅读 · 0 评论 -
LeetCode: 313. Super Ugly Number
LeetCode: 313. Super Ugly NumberWrite a program to find the nth super ugly number.Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k.Exampl...原创 2019-11-06 08:19:51 · 215 阅读 · 0 评论 -
LeetCode: 312. Burst Balloons
LeetCode: 312. Burst Balloons题目描述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 the balloons. If the you b...原创 2019-11-05 08:08:39 · 175 阅读 · 0 评论 -
LeetCode: 310. Minimum Height Trees
LeetCode: 310. Minimum Height Trees题目描述For an undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees,...原创 2019-11-02 10:56:53 · 142 阅读 · 0 评论 -
LeetCode: 309. Best Time to Buy and Sell Stock with Cooldown
LeetCode: 309. Best Time to Buy and Sell Stock with Cooldown题目描述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 maximum profit...原创 2019-10-29 11:23:57 · 119 阅读 · 0 评论 -
LeetCode: 307. Range Sum Query - Mutable
LeetCode: 307. Range Sum Query - Mutable题目描述Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.The update(i, val) function modifies nums by updatin...原创 2019-10-28 19:40:01 · 117 阅读 · 0 评论 -
LeetCode: 306. Additive Number
LeetCode: 306. Additive Number题目描述Additive number is a string whose digits can form additive sequence.A valid additive sequence should contain at least three numbers. Except for the first two numbe...原创 2019-10-26 12:48:45 · 165 阅读 · 0 评论 -
LeetCode: 304. Range Sum Query 2D - Immutable
LeetCode: 304. Range Sum Query 2D - Immutable题目描述Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row...原创 2019-10-25 22:02:30 · 107 阅读 · 0 评论 -
LeetCode: 303. Range Sum Query - Immutable
LeetCode: 303. Range Sum Query - Immutable题目描述Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRa...原创 2019-10-24 13:57:27 · 166 阅读 · 0 评论 -
LeetCode: 301. Remove Invalid Parentheses
LeetCode: 301. Remove Invalid Parentheses题目描述Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.**Note: **The input string may con...原创 2019-10-24 11:27:57 · 129 阅读 · 0 评论 -
LeetCode: 300. Longest Increasing Subsequence
LeetCode: 300. Longest Increasing Subsequence题目描述Given an unsorted array of integers, find the length of longest increasing subsequence.Example:Input: [10,9,2,5,3,7,101,18]Output: 4 Explanation:...原创 2019-10-23 15:31:06 · 145 阅读 · 0 评论 -
LeetCode: 299. Bulls and Cows
LeetCode: 299. Bulls and Cows题目描述You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend ma...原创 2019-10-23 14:32:33 · 182 阅读 · 0 评论 -
LeetCode: 297. Serialize and Deserialize Binary Tree
LeetCode: 297. Serialize and Deserialize Binary Tree题目描述ShareSerialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memo...原创 2019-10-23 10:26:47 · 162 阅读 · 0 评论 -
LeetCode: 290. Word Pattern
LeetCode: 290. Word Pattern题目描述Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and ...原创 2019-10-22 07:18:22 · 125 阅读 · 0 评论 -
LeetCode: 289. Game of Life
LeetCode: 289. Game of Life题目描述According to the Wikipedia’s article: “The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in ...原创 2019-10-21 18:20:27 · 279 阅读 · 0 评论 -
LeetCode: 287. Find the Duplicate Number
LeetCode: 287. Find the Duplicate Number题目描述Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assu...原创 2019-10-21 10:28:36 · 119 阅读 · 0 评论 -
LeetCode:282. Expression Add Operators
LeetCode:282. Expression Add Operators题目描述Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the digits ...原创 2019-10-19 21:07:34 · 100 阅读 · 0 评论 -
LeetCode:295. Find Median from Data Stream
LeetCode:295. Find Median from Data Stream题目描述Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two m...原创 2019-10-18 18:21:27 · 157 阅读 · 0 评论 -
LeetCode: 278. First Bad Version
LeetCode: 278. First Bad Version题目描述You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since ...原创 2019-03-11 07:54:34 · 110 阅读 · 0 评论 -
LeetCode: 275. H-Index II
LeetCode: 275. H-Index II题目描述Given an array of citations sorted in ascending order (each citation is a non-negative integer) of a researcher, write a function to compute the researcher’s h-index.Ac...原创 2019-03-08 08:09:04 · 114 阅读 · 0 评论 -
LeetCode: 274. H-Index
LeetCode: 274. H-IndexGiven an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher’s h-index.According to the definition of h-ind...原创 2019-03-07 08:25:05 · 130 阅读 · 0 评论 -
LeetCode: 273. Integer to English Words
LeetCode: 273. Integer to English WordsConvert a non-negative integer to its english words representation. Given input is guaranteed to be less than 23^1 - 1.Example 1:Input: 123Output: "One Hundr...原创 2019-03-05 08:22:21 · 117 阅读 · 0 评论 -
LeetCode: 260. Single Number III
LeetCode: 260. Single Number III题目描述Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear ...原创 2019-03-04 07:51:05 · 113 阅读 · 0 评论 -
LeetCode: 257. Binary Tree Paths
LeetCode: 257. Binary Tree Paths题目描述Given a binary tree, return all root-to-leaf paths.**Note: **A leaf is a node with no children.Example:Input: 1 / \2 3 \ 5Output: ["1->2-&g...原创 2019-03-03 12:02:56 · 142 阅读 · 0 评论 -
LeetCode: 242. Valid Anagram
LeetCode: 242. Valid Anagram题目描述Given two strings s and t , write a function to determine if t is an anagram of s.Example 1:Input: s = "anagram", t = "nagaram"Output: trueExample 2:Input: s = ...原创 2019-03-01 07:58:40 · 137 阅读 · 0 评论 -
LeetCode: 241. Different Ways to Add Parentheses
LeetCode: 241. Different Ways to Add Parentheses题目描述Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators...原创 2019-02-27 08:44:46 · 144 阅读 · 0 评论