LeetCode
TechJungle
这个作者很懒,什么都没留下…
展开
-
LeetCode BinarySearch 69. Sqrt(x)
69. Sqrt(x)Implement int sqrt(int x).Compute and return the square root of x, where x is guaranteed to be a non-negative integer.Since the return type is an integer, the decimal digits are truncate...原创 2019-12-24 09:55:20 · 95 阅读 · 0 评论 -
LeetCode BinarySearch 852. Peak Index in a Mountain Array 1095. Find in Mountain Array
852. Peak Index in a Mountain ArrayLet’s call an array A a mountain if the following properties hold:A.length >= 3There exists some 0 < i < A.length - 1 such thatA[0]<A[1]<...A[i−1...原创 2019-12-24 06:18:46 · 98 阅读 · 0 评论 -
LeetCode BinarySearch 162. Find Peak Element
162. Find Peak ElementA peak element is an element that is greater than its neighbors.Given an input array nums, where nums[i] ≠ nums[i+1], find a peak element and return its index.The array may co...原创 2019-12-24 05:38:42 · 95 阅读 · 0 评论 -
LeetCode BinarySearch 240. Search a 2D Matrix II
240. Search a 2D Matrix IIWrite an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left t...原创 2019-12-24 05:21:05 · 92 阅读 · 0 评论 -
LeetCode BinarySearch 74 Search a 2D Matrix
74. Search a 2D MatrixWrite an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The firs...原创 2019-12-24 00:52:08 · 68 阅读 · 0 评论 -
Leetcode BinarySearch 302 Smallest Rectangle Enclosing Black Pixels
302. Smallest Rectangle Enclosing Black PixelsAn image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black pixels are connected, i.e., there is only one black ...原创 2019-12-23 13:12:58 · 142 阅读 · 0 评论 -
LeetCode BinarySearch 33 & 81 Search in Rotated Sorted Array I II
33. Search in Rotated Sorted ArraySuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).You are given a ...原创 2019-12-23 13:10:56 · 100 阅读 · 0 评论 -
Leetcode BinarySearch 153 154 Find Minimum in Rotated Sorted Array l & ll
153. Find Minimum in Rotated Sorted ArraySuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).Find th...原创 2019-12-22 09:14:01 · 59 阅读 · 0 评论 -
LeetCode BinarySearch 702 Search in a Sorted Array of Unknown Size
702. Search in a Sorted Array of Unknown SizeGiven an integer array sorted in ascending order, write a function to search target in nums. If target exists, then return its index, otherwise return -1...原创 2019-12-22 05:14:22 · 157 阅读 · 0 评论 -
LeetCode BinarySearch 278 first bad version
Leetcode 278 first bad versionYou 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 each ve...原创 2019-12-22 04:28:29 · 64 阅读 · 0 评论 -
LeetCode BinarySearch 34 Find First and Last Position of Element in Sorted Array
34. Find First and Last Position of Element in Sorted ArrayGiven an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.Your algorithm’s r...原创 2019-12-22 03:48:29 · 49 阅读 · 0 评论 -
LeetCode Backtracking 46 Permutations 47 Permutationsll
46. PermutationsGiven a collection of distinct integers, return all possible permutations.Example:Input: [1,2,3]Output:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]solution由于是要得到所有的排...原创 2019-12-22 00:53:46 · 94 阅读 · 0 评论 -
LeetCode DFS 78 Subsets 90 Subsets ll
SubsetsGiven a set of distinct integers, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.Example:Input: nums = [1,2,3]Output:[[3],...原创 2019-12-21 13:24:29 · 91 阅读 · 0 评论 -
LeetCode Array 289 Game of Life
289. Game of Life (Medium)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 1970.”...原创 2019-12-21 09:19:26 · 95 阅读 · 0 评论 -
LeetCode String 20 Valid Parentheses
20. Valid ParenthesesGiven a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.An input string is valid if:Open brackets must be closed b...原创 2019-12-19 14:31:16 · 60 阅读 · 0 评论 -
LeetCode String 336 Palindrome Pairs
336. Palindrome PairsGiven a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome.E...原创 2019-12-19 14:05:45 · 108 阅读 · 0 评论 -
LeetCode String 125 Valid Palindrome
125. Valid PalindromeGiven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note: For the purpose of this problem, we define empty string as val...原创 2019-12-19 08:46:24 · 81 阅读 · 0 评论 -
LeetCode String 65 Valid Number
65. Valid NumberValidate if a given string can be interpreted as a decimal number.Some examples:“0” => true" 0.1 " => true“abc” => false“1 a” => false“2e10” => true" -90e3 " =...原创 2019-12-19 05:34:12 · 70 阅读 · 0 评论 -
LeetCode String 68 Text Justification
68. Text JustificationGiven an array of words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified.You should pack your w...原创 2019-12-19 04:41:33 · 63 阅读 · 0 评论 -
LeetCode String 157 158 Read N Characters Given Read4 I and II
157. Read N Characters Given Read4Given a file and assume that you can only read the file using a given method read4, implement a method to read n characters.Method read4:The API read4 reads 4 cons...原创 2019-12-19 01:17:16 · 132 阅读 · 0 评论 -
LeetCode String 273 Integer to English Words
273. Integer to English WordsConvert a non-negative integer to its english words representation. Given input is guaranteed to be less than 2312^{31}231 - 1.Example 1:Input: 123Output: “One Hundred...原创 2019-12-18 09:18:35 · 78 阅读 · 0 评论 -
LeetCode String 12 Integer to Roman
12. Integer to RomanRoman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C ...原创 2019-12-18 08:57:22 · 73 阅读 · 0 评论 -
LeetCode String 13 Roman to Integer
13. Roman to IntegerRoman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C ...原创 2019-12-18 00:18:54 · 89 阅读 · 0 评论 -
LeetCode String 171 Excel Sheet Column Number
171. Excel Sheet Column NumberGiven a column title as appear in an Excel sheet, return its corresponding column number.For example:A -> 1B -> 2C -> 3...Z -> 26AA -> 27AB -> ...原创 2019-12-17 23:58:23 · 79 阅读 · 0 评论 -
LeetCode String 168 Excel Sheet Column Title
168. Excel Sheet Column TitleGiven a positive integer, return its corresponding column title as appear in an Excel sheet.For example:1 -> A2 -> B3 -> C…26 -> Z27 -> AA28 -> ...原创 2019-12-06 04:22:52 · 57 阅读 · 0 评论 -
LeetCode String 38 Count and Say
38. Count and SayThe count-and-say sequence is the sequence of integers with the first five terms as following:1112112111112211 is read off as “one 1” or 11.11 is read off as ...原创 2019-12-01 12:46:49 · 73 阅读 · 0 评论 -
LeetCode String 161 One Edit Distance
161. One Edit DistanceGiven two strings s and t, determine if they are both one edit distance apart.Note:There are 3 possiblities to satisify one edit distance apart:Insert a character into s to g...原创 2019-12-01 11:32:43 · 92 阅读 · 0 评论 -
LeetCode String 6 ZigZag Conversion
6. ZigZag ConversionThe string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)And t...原创 2019-12-01 06:11:12 · 50 阅读 · 0 评论 -
LeetCode String 179 Largest Number
179. Largest NumberGiven a list of non negative integers, arrange them such that they form the largest number.Example 1:Input: [10,2]Output: “210”Example 2:Input: [3,30,34,5,9]Output: “9534330”...原创 2019-12-01 04:16:31 · 84 阅读 · 0 评论 -
LeetCode String 49 Group Anagrams
49. Group AnagramsGiven an array of strings, group anagrams together.Example:Input: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”],Output:[[“ate”,“eat”,“tea”],[“nat”,“tan”],[“bat”]]Note:All inp...原创 2019-11-30 02:55:50 · 78 阅读 · 0 评论 -
LeetCode String 28 Implement 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 haystack.Example 1:Input: haystack = “hello”, needle = “ll”...原创 2019-11-19 13:18:42 · 66 阅读 · 0 评论 -
LeetCode String 14 Longest Common Prefix
14. Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string “”.Example 1:Input: [“flower”,“...原创 2019-11-20 10:49:28 · 52 阅读 · 0 评论 -
LeetCode String 58 Length of Last Word
58. Length of Last WordGiven a string s consists of upper/lower-case alphabets and empty space characters ’ ', return the length of last word in the string.If the last word does not exist, return 0....原创 2019-11-20 11:07:09 · 86 阅读 · 0 评论 -
LeetCode String 387 First Unique Character in a String
387. First Unique Character in a StringGiven a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1.Examples:s = “leetcode”return 0.s = “lov...原创 2019-11-20 11:38:26 · 72 阅读 · 0 评论 -
LeetCode String 383. Ransom Note
383. Ransom NoteGiven an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from t...原创 2019-11-21 10:23:52 · 98 阅读 · 0 评论 -
LeetCode String 344 Reverse String
344. Reverse StringWrite a function that reverses a string. The input string is given as an array of characters char[].Do not allocate extra space for another array, you must do this by modifying th...原创 2019-11-21 10:27:38 · 54 阅读 · 0 评论 -
LeetCode String 151 Reverse Words in a String
151. Reverse Words in a StringGiven an input string, reverse the string word by word.Example 1:Input: “the sky is blue”Output: “blue is sky the”Example 2:Input: " hello world! "Output: “world...原创 2019-11-21 10:32:14 · 73 阅读 · 0 评论 -
LeetCode String 345 Reverse Vowels of a String
345. Reverse Vowels of a StringWrite a function that takes a string as input and reverse only the vowels of a string.Example 1:Input: “hello”Output: “holle”Example 2:Input: “leetcode”Output: “l...原创 2019-11-21 14:04:20 · 80 阅读 · 0 评论 -
LeetCodeString 205 Isomorphic Strings
205. Isomorphic StringsGiven two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be ...原创 2019-11-28 03:42:25 · 64 阅读 · 0 评论 -
LeetCode String 290 Word Pattern
290. Word PatternGiven 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 a non-empty wor...原创 2019-11-28 04:11:03 · 70 阅读 · 0 评论