
LeetCode
文章平均质量分 84
CristianoJason
宏愿纵未了,奋斗总不太晚。
展开
-
[LeetCode]TwoSum解题报告
一、问题描述:Given an arrayof 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.Example:Given nu原创 2016-04-03 18:21:09 · 552 阅读 · 0 评论 -
[Leetcode]Substring with Concatenation of All Words & Minimum Window Substring
这两道题有一定的联系和区别:这类寻找子序列组合的题目大都可以采取双指针+Map的思想进行处理。Substring with Concatenation of All Words中,给定了一些等长的单词words,要求在指定字符串s中找出这些单词的连续组合序列;Minimum Window Substring中,给定了一个子串t,要求在指定字符串s中找出子串t中所有字母所构成的最短子原创 2016-09-03 01:01:20 · 479 阅读 · 0 评论 -
[LeetCode]SudokuSolver解决数独问题
一、 问题描述: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.原创 2016-09-03 16:37:51 · 723 阅读 · 0 评论 -
[LeetCode]Buy and Sell Stocks 买卖股票问题
LeetCode上关于买卖股票的问题一共有五道,题号分别为121,122,123,188,309。此类问题的基本描述即给出一个序列prices[],prices[i]代表第i天股票的价格。如果当天之前不持有股票,则可以以prices[i]的价格购入股票;如果当天之前持有股票,则可以以prices[i]的价格卖出股票;当然,当天也可任何操作都不进行。目的就是求该阶段的最大收益。原创 2016-09-10 15:22:33 · 4306 阅读 · 0 评论 -
[LeetCode]Maximal Rectangle寻找最大矩形
一、 题目描述: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 following matrix:1 0 1 0 01 0 1 1 11 1原创 2016-09-05 00:32:14 · 2511 阅读 · 0 评论 -
[LeetCode]KMP——字符串匹配
一、问题描述:https://leetcode.com/problems/implement-strstr/Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.原创 2016-04-24 19:53:06 · 4924 阅读 · 0 评论 -
[LeetCode]Multiply Strings
一、问题描述:Given two numbers represented as strings, return multiplication of the numbers as a string.Note:The numbers can be arbitrarily large and are non-negative.Converting the input stri原创 2016-04-20 11:21:39 · 501 阅读 · 0 评论 -
[LeetCode]Permutation全排列和去重全排列
一、问题描述:借助这道题总结一下全排列问题吧https://leetcode.com/problems/permutations/Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following p原创 2016-04-20 14:02:34 · 3794 阅读 · 0 评论 -
[LeetCode]Next Permutation下一个排列问题
当初把自己的代码贴在了discuss上,最近有人关于代码部分问了一些问题,现在总结一下这个题目吧。一、问题描述Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such a原创 2016-04-30 00:12:13 · 629 阅读 · 0 评论 -
[LeetCode]Unique Binary Search Trees II生成所有二叉搜索树
一、问题描述:Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below.原创 2016-04-28 22:28:08 · 561 阅读 · 0 评论 -
[LeetCode]Candy——分糖果问题
一、问题描述:There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must原创 2016-04-27 15:03:30 · 2074 阅读 · 0 评论 -
[LeetCode]RemoveDuplicateLetters解题思路
一、问题描述:Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicograp原创 2016-04-27 12:11:54 · 885 阅读 · 0 评论 -
[LeetCode]Majority Element(献上膝盖的一题)
一、问题描述:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the原创 2016-09-06 14:45:52 · 529 阅读 · 0 评论