Quantcast
Channel: 书影 - Entries for the tag leetcode
Browsing all 559 articles
Browse latest View live

[LeetCode]Is Subsequence

题目描述:LeetCode 392. Is SubsequenceGiven a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a very...

View Article


[LeetCode]UTF-8 Validation

题目描述:LeetCode 393. UTF-8 ValidationA character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules:A character in UTF8 can be from 1 to 4 bytes long, subjected to the following...

View Article


[LeetCode]Decode String

题目描述:LeetCode 394. Decode StringGiven an encoded string, return it's decoded string.The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated...

View Article

[LeetCode]Longest Substring with At Least K Repeating Characters

题目描述:LeetCode 395. Longest Substring with At Least K Repeating CharactersFind the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T...

View Article

LeetCode Weekly Contest 3解题报告

LeetCode Weekly Contest 3是LeetCode举办的第二场正式周赛,共4道题目,比赛时长2.5小时。比赛链接:https://leetcode.com/contest/detail/3题解列表:LeetCode 392. Is SubsequenceLeetCode 393. UTF-8 ValidationLeetCode 394. Decode StringLeetCode...

View Article


[LeetCode]Next Permutation

题目描述:LeetCode 31. Next PermutationImplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must...

View Article

[LeetCode]Permutations

题目描述:LeetCode 46. PermutationsGiven a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1],...

View Article

[LeetCode]Rotate Function

题目描述:LeetCode 396. Rotate FunctionGiven an array of integers A and let n to be its length.Assume Bk to be an array obtained by rotating the array Ak positions clock-wise, we define a "rotation...

View Article


[LeetCode]Integer Replacement

题目描述:LeetCode 397. Integer ReplacementGiven a positive integer n and you can do operations as follow:If n is even, replace n with n/2.If n is odd, you can replace n with either n + 1 or n - 1.What is...

View Article


[LeetCode]Random Pick Index

题目描述:LeetCode 398. Random Pick IndexGiven an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in...

View Article

[LeetCode]Evaluate Division

题目描述:LeetCode 399. Evaluate Divisionp> Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some...

View Article

LeetCode Weekly Contest 4解题报告

LeetCode Weekly Contest 4是LeetCode举办的第三场正式周赛,共4道题目,比赛时长2.5小时。比赛链接:https://leetcode.com/contest/detail/4题解列表:LeetCode 396. Rotate FunctionLeetCode 397. Integer ReplacementLeetCode 398. Random Pick...

View Article

[LeetCode]Nth Digit

题目描述:LeetCode 400. Nth DigitFind the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...Note:n is positive and will fit within the range of a 32-bit signed integer (n<...

View Article


Image may be NSFW.
Clik here to view.

[LeetCode]Binary Watch

题目描述:LeetCode 401. Binary WatchA binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).Each LED represents a zero or one, with...

View Article

[LeetCode]Remove K Digits

题目描述:LeetCode 402. Remove K DigitsGiven a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible.Note:The length of num is...

View Article


[LeetCode]Frog Jump

题目描述:LeetCode 403. Frog JumpA frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but it must not jump into...

View Article

LeetCode Weekly Contest 5解题报告

LeetCode Weekly Contest 5是LeetCode举办的第四场正式周赛,共4道题目,比赛时长2.5小时。比赛链接:https://leetcode.com/contest/detail/5题解列表:LeetCode 400. Nth DigitLeetCode 401. Binary WatchLeetCode 402. Remove K DigitsLeetCode 403....

View Article


[LeetCode]Sum of Left Leaves

题目描述:LeetCode 404. Sum of Left LeavesFind the sum of all left leaves in a given binary tree.Example: 3 / \ 9 20 / \ 15 7 There are two left leaves in the binary tree, with values 9 and 15 respectively....

View Article

[LeetCode]Convert a Number to Hexadecimal

题目描述:LeetCode 405. Convert a Number to HexadecimalGiven an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used.IMPORTANT: You must not use...

View Article

[LeetCode]Queue Reconstruction by Height

题目描述:LeetCode 406. Queue Reconstruction by HeightSuppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person...

View Article
Browsing all 559 articles
Browse latest View live