LeetCode学习笔记
文章平均质量分 67
记录博主LeetCode学习的过程
yanqinghe123
这个作者很懒,什么都没留下…
展开
-
LeetCode36-Valid Sudoku
Valid Sudoku今天刷到LeetCode的第36题,题目详情如下题目描述 Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled with the原创 2017-09-17 16:29:47 · 200 阅读 · 0 评论 -
LeetCode1_Two Sum
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 have exactly one solution, and you may not us原创 2017-09-17 16:31:55 · 240 阅读 · 0 评论 -
LeetCode37 - Sudoku Solver
Sudoku Solver题目描述 Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by the character ‘.’. You may assume that there will be only one unique solution原创 2017-09-17 18:28:31 · 204 阅读 · 0 评论 -
LeetCode38 - Count and Say
Count and Say问题描述 The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 2. 11 3. 21 4. 1211 5. 111221 1原创 2017-09-17 19:51:18 · 219 阅读 · 0 评论 -
LeetCode39 - Combination Sum
Combination Sum问题描述 Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated原创 2017-09-18 23:38:20 · 438 阅读 · 0 评论 -
LeetCode40 - Combination Sum II
Combination Sum II问题表示 Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each number in C may only be原创 2017-09-19 21:32:09 · 357 阅读 · 0 评论 -
LeetCode41 - First Missing Positive
First Missing Positive问题描述 Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2. Your algorithm shoul原创 2017-09-19 23:36:20 · 259 阅读 · 0 评论 -
LeetCode42_Trapping Rain Water
Trapping Rain Water问题描述 Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. For example, Gi原创 2017-09-24 20:16:56 · 172 阅读 · 0 评论 -
LeetCode43_Multiply Strings
Multiply Strings问题描述 Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2. **Note: The length of both num1 and num2 is < 110. Both nu原创 2017-09-24 20:52:32 · 267 阅读 · 0 评论 -
LeetCode44_Wildcard Matching
Wildcard Matching问题描述 Implement wildcard pattern matching with support for ‘?’ and ‘*’. ‘?’ Matches any single character. ‘*’ Matches any sequence of characters (including the empty sequence).原创 2017-09-24 22:33:58 · 267 阅读 · 0 评论 -
LeetCode55_Jump Game
Jump Game问题描述 Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that positio原创 2017-09-24 22:49:38 · 163 阅读 · 0 评论 -
LeetCode45_Jump Game II
Jump Game II问题描述 Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that posi原创 2017-09-25 17:48:30 · 198 阅读 · 0 评论 -
LeetCode46_Permutations
Permutations问题描述 Given 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],原创 2017-09-25 17:57:48 · 179 阅读 · 0 评论 -
LeetCode47_Permutations II
Permutations II问题描述 Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2] have the following unique permutations:[ [1,1,2原创 2017-09-25 18:20:52 · 163 阅读 · 0 评论 -
LeetCode48_Rotate Image
Rotate Image问题描述 You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in-place, which means you have to原创 2017-09-25 18:27:59 · 184 阅读 · 0 评论 -
LeetCode49_Group Anagrams
Group Anagrams问题描述 Given an array of strings, group anagrams together. For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”], Return:[ ["ate", "eat","tea"], ["nat","tan"], ["原创 2017-09-25 18:48:23 · 132 阅读 · 0 评论 -
LeetCode50_Pow(x,n)
Pow(x, n)问题描述 Implement pow(x, n).简单分析这道题的问题描述十分简单,就是自己实现一下pow(x,n)这个函数。对于幂函数,循环乘法是最简单的做法,但是效率太低了,那么有什么简单的做法吗?根据一个基本定理 n看成是以2为基的位构成的,因此每一位是对应x的一个幂数,然后迭代直到n到最高位。比如说第一位对应x,第二位对应x*x,第三位对应x^4,…,第k位对应x^原创 2017-09-25 19:04:50 · 152 阅读 · 0 评论 -
LeetCode57 Insert Interval
Insert Interval问题描述 Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according原创 2017-10-08 20:14:01 · 323 阅读 · 0 评论 -
LeetCode63 Unique Paths II
Unique Paths II问题描述 Follow up for “Unique Paths”: Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space is marked as 1 and原创 2017-10-08 20:20:46 · 174 阅读 · 0 评论 -
LeetCode64 Minimum Path Sum
Minimum Path Sum问题描述 Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move原创 2017-10-08 20:30:50 · 207 阅读 · 0 评论 -
LeetCode65 Valid Number
LeetCode65 Valid Number问题描述 Validate if a given string is numeric. Some examples: “0” => true ” 0.1 ” => true “abc” => false “1 a” => false “2e10” => true Note: It is intended原创 2017-10-08 20:44:07 · 1000 阅读 · 0 评论 -
LeetCode66 Plus One
LeetCode66 Plus One问题描述 Given a non-negative integer represented as a non-empty array of digits, plus one to the integer. You may assume the integer do not contain any leading zero, except the num原创 2017-10-08 20:51:27 · 238 阅读 · 0 评论 -
LeetCode67 Add Binary
LeetCode67 Add Binary问题描述 Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100".简单分析这道题目其实就求两个字符串和的变种形式。只是求得是2进制格式,一样需要考虑两个字符串的长原创 2017-10-08 21:00:28 · 201 阅读 · 0 评论 -
LeetCode68 Text Justification
LeetCode68 Text Justification问题描述 Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. You should pack yo原创 2017-10-08 21:14:25 · 217 阅读 · 0 评论 -
LeetCode69 Sqrt(x)
LeetCode69 Sqrt(x)问题描述 Implement int sqrt(int x). Compute and return the square root of x.简单介绍这道题的就是实现sqrt方法。可以采用二分法进行,寻找适合的整数。但是网上很多博客都再说这个超出int范围的事情,我倒认为既然平方都是int范围内的,那么这个数字肯定也在int内,而数字肯定不大于4原创 2017-10-08 21:24:15 · 190 阅读 · 0 评论 -
LeetCode71 Simplify Path
LeetCode71 Simplify Path问题描述Given an absolute path for a file (Unix-style), simplify it.For example, path = “/home/”, =>“/home”path = “/a/./b/../../c/”, => “/c”简单分析这道题就是简化路径,看到这个路径我就想到了坑爹的windows系列路径分原创 2017-10-08 21:36:24 · 256 阅读 · 0 评论 -
LeetCode72 Edit Distance
LeetCode72 Edit Distance问题描述 Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3原创 2017-10-08 22:05:36 · 188 阅读 · 0 评论 -
LeetCode73 Set Matrix Zeroes
LeetCode73 Set Matrix Zeroes问题描述 Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. click to show follow up. Follow up: Did you use extra space原创 2017-10-10 18:31:11 · 192 阅读 · 0 评论 -
LeetCode74 Search a 2D Matrix
LeetCode74 Search a 2D Matrix问题描述 Write 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 t原创 2017-10-10 18:37:49 · 152 阅读 · 0 评论 -
LeetCode75 Sort Colors
LeetCode75 Sort Colors问题描述 Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. H原创 2017-10-10 18:50:34 · 151 阅读 · 0 评论 -
LeetCode76 Minimum Window Substring
LeetCode76 Minimum Window Substring问题描述 Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example, S = “ADOBECOD原创 2017-10-10 19:01:44 · 154 阅读 · 0 评论 -
LeetCode77 Combinations
LeetCode77 Combinations问题描述 Given two integers n and k, return all possible combinations of k numbers out of 1 … n. For example, If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3],原创 2017-10-10 19:17:54 · 194 阅读 · 0 评论 -
LeetCode78 SubSets
LeetCode78 SubSets问题描述 Given a set of distinct integers, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. For example, If nums = [1,2,3], a s原创 2017-10-10 19:24:51 · 208 阅读 · 0 评论 -
LeetCode79 Word Search
LeetCode79 Word Search问题描述 Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are th原创 2017-10-10 19:30:01 · 186 阅读 · 0 评论 -
LeetCode80 Remove Duplicates from Sorted Array II
LeetCode80 Search in Rotated Sorted Array II问题描述 Follow up for “Search in Rotated Sorted Array”: What if duplicates are allowed? Would this affect the run-time complexity? How and w原创 2017-10-10 19:37:04 · 158 阅读 · 0 评论 -
LeetCode81 Search in Rotated Sorted Array II
LeetCode81 Search in Rotated Sorted Array II问题描述 Follow up for “Search in Rotated Sorted Array”: What if duplicates are allowed? Would this affect the run-time complexity? How and why? Sup原创 2017-10-10 21:42:14 · 192 阅读 · 0 评论 -
LeetCode83 Remove Duplicates from Sorted List
LeetCode83 Remove Duplicates from Sorted List问题链接 LeetCode83问题描述 Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, retur原创 2017-10-15 21:11:33 · 219 阅读 · 0 评论 -
LeetCode84 Largest Rectangle in Histogram
LeetCode84 Largest Rectangle in Histogram问题链接 LeetCode84问题描述 Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle原创 2017-10-15 21:29:50 · 212 阅读 · 0 评论 -
LeetCode85 Maximal Rectangle
LeetCode85 Maximal Rectangle问题来源 LeetCode85问题描述 Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s and return its area. For example, given the follo原创 2017-10-15 21:40:19 · 212 阅读 · 0 评论 -
LeetCode86 Partition List
LeetCode86 Partition List问题来源LeetCode86问题描述 Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the原创 2017-10-15 21:48:00 · 186 阅读 · 0 评论