![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
文章平均质量分 69
BoomHusky
计算机专业硕士,希望自己的实力能够更强
展开
-
Leetcode | 16. 3Sum Closest twoPoint方法拓展
Givenan array nums of n integers and an integer target, find three integers in nums such that the sum is closestto target. Return thesum of the three integers. You may assume that each input would hav...原创 2018-06-19 17:52:05 · 178 阅读 · 0 评论 -
LeetCode | 7. Reverse Integer 数字反向循环技巧题
Givena 32-bit signed integer, reverse digits of an integer.Example1:Input: 123Output: 321Example2:Input: -123Output: -321Example3:Input: 120Output: 21Note:Assume we a原创 2018-02-04 15:35:43 · 136 阅读 · 0 评论 -
LeetCode | 149. Max Points on a Line求多个点里面在一条直线上的点最多有多少个难题
Given n points on a 2D plane, find the maximumnumber of points that lie on the same straight line.感觉我的想法太复杂了,不过暂时也只想得到这个方法,我的方法大概的原理是两点决定一条直线,首先遍历原点数组,将其中的相同的点复制到另外一个点数组里面去,这样另外一个点的数组就不会有重复的点,然后原创 2018-02-04 15:33:44 · 791 阅读 · 0 评论 -
LeetCode | 30. Substring with Concatenation of All Words字符串技巧难题
You are given a string, s,and a list of words, words,that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each wordin words exactly once and wit原创 2018-02-04 15:32:36 · 171 阅读 · 0 评论 -
LeetCode | 769. Max Chunks To Make Sorted将数组划分成多个部分贪心算法
Givenan array arr that is a permutation of [0, 1, ...,arr.length - 1], we split the array into some numberof "chunks" (partitions), and individually sort each chunk. After concatenating them, the re原创 2018-02-04 15:30:18 · 287 阅读 · 0 评论 -
LeetCode | 448. Find All Numbers Disappeared in an Array 数组技巧题
Givenan array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and othersappear once.Findall the elements of [1, n] inclusive that do not appear inthis array.Couldy原创 2018-02-04 15:29:08 · 114 阅读 · 0 评论 -
LeetCode | 767. Reorganize String调整字符串使得字符串相同字符不相邻
Givena string S, check if the letters can berearranged so that two characters that are adjacent to each other are not thesame.Ifpossible, output any possible result. If not possible, return the e原创 2018-02-04 15:27:35 · 2831 阅读 · 0 评论 -
LeetCode | 766. Toeplitz Matrix矩阵操作水题
766. Toeplitz MatrixAmatrix is Toeplitz if every diagonal from top-left to bottom-right has the sameelement.Nowgiven an M x N matrix, return True if and only if the matrix is Toeplitz. Examp原创 2018-02-04 15:25:28 · 197 阅读 · 0 评论 -
LeetCode | 758. Bold Words in String 简单技巧题
Givena set of keywords words and a string S, make all appearances of allkeywords in S bold.Any letters between and tags become bold.Thereturned string should use the least number of tags possibl原创 2018-01-08 11:45:44 · 852 阅读 · 0 评论 -
LeetCode | 45. Jump Game IIDP或贪心难题
Given an array of non-negative integers, you are initiallypositioned at the first index of the array.Each element in the array represents your maximum jump length atthat position.Your goal is to r原创 2018-01-26 12:54:42 · 231 阅读 · 0 评论 -
LeetCode | 43. Multiply Strings大数相乘
Giventwo non-negative integers num1 and num2 representedas strings, return the product of num1 and num2.Note:1. The length of both num1 and num2 is< 110.2. Both num1 and num2 conta原创 2018-01-26 12:49:36 · 227 阅读 · 0 评论 -
LeetCode | 632. Smallest Range求多个数组拥有最小范围的一个交集难题
Youhave k lists of sorted integers in ascending order. Find the smallest rangethat includes at least one number from each of thek lists.Wedefine the range [a,b] is smaller than range [c,d] if b-a原创 2018-01-26 12:43:10 · 592 阅读 · 1 评论 -
LeetCode | 76. Minimum Window Substring多区域覆盖难题
Given a string S and a string T, find the minimum window in Swhich will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BANC".No原创 2018-01-26 12:42:16 · 184 阅读 · 0 评论 -
LeetCode | 695. Max Area of Island BFS
Givena non-empty 2D array grid of0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontalor vertical.) You may assume all four edges of the grid are surroun原创 2018-01-26 12:39:22 · 172 阅读 · 0 评论 -
LeetCode | 684. Redundant Connection 拓扑排序中等难度
Inthis problem, a tree is an undirected graph that is connected and has no cycles.Thegiven input is a graph that started as a tree with N nodes (with distinctvalues 1, 2, ..., N), with one additio原创 2018-01-26 12:37:44 · 314 阅读 · 0 评论 -
LeetCode | 407. Trapping Rain Water II矩阵存水难题算法
Givenan m x n matrix of positive integers representing the height of eachunit cell in a 2D elevation map, compute the volume of water it is able to trapafter raining.Note:Both m and n are less原创 2018-02-02 12:57:47 · 542 阅读 · 0 评论 -
LeetCode | 49. Group Anagrams 哈希表
Givenan array of strings, group anagrams together.Forexample, given: ["eat", "tea", "tan","ate", "nat", "bat"], Return:[ ["ate","eat","tea"], ["nat","tan"], ["bat"]]这题记住很重要的几点能够非原创 2018-02-04 15:37:42 · 165 阅读 · 0 评论 -
LeetCode | 27. Remove Element贪心算法循环技巧题
Givenan array and a value, remove all instances of that value in-place andreturn the new length.Donot allocate extra space for another array, you must do this by modifying the input array in-place原创 2018-02-04 15:38:59 · 147 阅读 · 0 评论 -
LeetCode | 389. Find the Difference 字符串
Giventwo strings s and t which consist of only lowercase letters.String t isgenerated by random shuffling string s andthen add one more letter at a random position.Findthe letter that was added in t.E...原创 2018-06-09 21:27:04 · 188 阅读 · 0 评论 -
LeetCode | 204. Count Primes 数论 素数筛选,厄拉多塞筛法
Count the number of prime numbers less than a non-negativenumber, n.Example:Input: 10Output: 4Explanation: There are 4 prime numbers less than10, they are 2, 3, 5, 7.这一题给你一个n,让你统计小于N的所有的素数的个数。假如按照传统的方...原创 2018-06-07 15:39:51 · 416 阅读 · 0 评论 -
LeetCode | 365. Water and Jug Problem 数学原理详细分析
Youare given two jugs with capacities x and y litres.There is an infinite amount of water supply available. You need to determinewhether it is possible to measure exactly z litresusing these two jugs....原创 2018-05-17 10:42:12 · 843 阅读 · 0 评论 -
LeetCode | 216. Combination Sum III BFS
Findall possible combinations of k numbers that add up to a number n,given that only numbers from 1 to 9 can be used and each combination should bea unique set of numbers.Example1:Input: k =3, n = 7Ou...原创 2018-04-21 14:39:17 · 138 阅读 · 0 评论 -
LeetCode | 357. Count Numbers with Unique Digits 数论
Given a non-negative integer n, count all numbers withunique digits, x, where 0 ≤ x < 10n.Example:Given n = 2, return 91. (The answer should be the total numbers in the range of0 ≤ x < 100, excl...原创 2018-05-01 16:42:32 · 112 阅读 · 0 评论 -
LeetCode | 188. Best Time to Buy and Sell Stock IV DP难题
Say you have an array for which the ith elementis the price of a given stock on day i.Design an algorithm to find the maximum profit. You may completeat most k transactions.Note:You may not engage in ...原创 2018-04-24 10:36:06 · 279 阅读 · 0 评论 -
LeetCode | 13. Roman to Integer 字符串规则
Romannumerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D 500M ...原创 2018-05-01 13:59:32 · 128 阅读 · 0 评论 -
leetcode Weekly Contest 77 807. Max Increase to Keep City Skyline
In a 2 dimensional array grid, eachvalue grid[i][j] representsthe height of a building located there. We are allowed to increase the heightof any number of buildings, by any amount (the amounts can be...原创 2018-04-05 14:53:01 · 201 阅读 · 0 评论 -
leetcode Weekly Contest 77 804. Unique Morse Code Words
International Morse Code defines a standard encodingwhere each letter is mapped to a series of dots and dashes, as follows: "a" mapsto ".-", "b" mapsto "-...", "c" mapsto "-.-.", and so on.For con原创 2018-04-05 14:52:27 · 119 阅读 · 0 评论 -
leetcode Weekly Contest 77 806. Number of Lines To Write String
806. Number of Lines To Write StringMy SubmissionsBack to Contest· User Accepted:1585· User Tried:1647· Total Accepted:1607· Total Submissions:2257· Difficulty:EasyWe are...原创 2018-04-05 14:51:50 · 148 阅读 · 0 评论 -
LeetCode | 372. Super Pow 数学原理题
Yourtask is to calculate ab mod 1337 where a is a positive integer and b isan extremely large positive integer given in the form of an array.Example1:a = 2b = [3] Result: 8Example2原创 2018-01-30 16:51:24 · 165 阅读 · 0 评论 -
LeetCode | 6. ZigZag Conversion 循环技巧题
Thestring "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows likethis: (you may want to display this pattern in a fixed font for betterlegibility)P A H NA P L S I原创 2018-01-30 16:50:01 · 138 阅读 · 0 评论 -
LeetCode | 121. Best Time to Buy and Sell Stock循环技巧题
Sayyou have an array for which the ith element is the price of a given stock on day i.Ifyou were only permitted to complete at most one transaction (ie, buy one andsell one share of the stock), de原创 2018-01-30 16:49:14 · 119 阅读 · 0 评论 -
LeetCode | 55. Jump Game循环技巧题
Given an array of non-negative integers, you are initiallypositioned at the first index of the array.Each element in the array represents your maximum jump length atthat position.Determine if you原创 2018-01-30 16:47:50 · 134 阅读 · 0 评论 -
LeetCode | 779. K-th Symbol in Grammar数学原理题
Onthe first row, we write a 0. Now in every subsequent row, we look at the previous rowand replace each occurrence of 0 with 01, and each occurrence of 1 with 10.Givenrow N and index K, return原创 2018-02-04 15:39:49 · 598 阅读 · 0 评论 -
LeetCode | 717. 1-bit and 2-bit Characters水题
canbe represented by two bits (10 or 11).Nowgiven a string represented by several bits. Return whether the last charactermust be a one-bit character or not. The given string will always end with aze原创 2018-02-02 12:55:51 · 236 阅读 · 0 评论 -
LeetCode | 27. Remove Element循环技巧题
Givenan array and a value, remove all instances of that value in-place and return the new length.Donot allocate extra space for another array, you must do this by modifying the input array in-plac原创 2018-02-02 12:54:29 · 126 阅读 · 0 评论 -
LeetCode | 553. Optimal Division Dp
Givena list of positiveintegers, the adjacent integers will performthe float division. For example, [2,3,4] -> 2 / 3 / 4.However,you can add any number of parenthesis at any position to change the原创 2018-02-01 20:14:06 · 215 阅读 · 0 评论 -
LeetCode | 475. Heaters 循环技巧题
Winteris coming! Your first job during the contest is to design a standard heaterwith fixed warm radius to warm all the houses.Now,you are given positions of houses and heaters on a horizontal line,原创 2018-01-03 16:42:42 · 136 阅读 · 0 评论 -
LeetCode | 52. N-Queens II 经典算法n后问题回溯法
Follow up for N-Queens problem.Now, instead outputting board configurations, return the totalnumber of distinct solutions.经典算法值n后问题,这题题给你一个n*n的棋盘,问你放置n个皇后共有多少种不用的放置方法,这一一个典型的回溯法框架,并且也是很简单的一个回溯原创 2018-01-03 16:44:01 · 150 阅读 · 0 评论 -
LeetCode刷题 | 473. Matchsticks to Square 深度优先遍历
Remember the story of Little Match Girl? By now, you knowexactly what matchsticks the little match girl has, please find out a way youcan make one square by using up all those matchsticks. You should原创 2017-12-26 15:49:49 · 415 阅读 · 0 评论 -
LeetCode | 689. Maximum Sum of 3 Non-Overlapping Subarrays 困难DP题分析与解答
Ina given array nums ofpositive integers, find three non-overlapping subarrays with maximum sum.Eachsubarray will be of size k, and we want to maximize the sum of all 3*k entries.Returnthe resul原创 2018-01-13 13:45:34 · 733 阅读 · 0 评论