
经典的leetcode题
i-Blue
抱平常心走平常路
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
26. Remove Duplicates from Sorted Array(删除已排序数组中的重复数)-two pointers
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with原创 2016-11-07 20:32:14 · 326 阅读 · 0 评论 -
20. Valid Parentheses--合法的括号组合(使用stack)
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all vali原创 2016-11-23 14:39:25 · 343 阅读 · 0 评论 -
Implement strStr()--字符串匹配_kmp_bkdHash
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.两种方法:1)bkdHash2)kmp代码分别如下://bkdHashint strStr(string原创 2016-12-08 19:08:11 · 389 阅读 · 0 评论 -
204. Count Primes_找n以内的质数_hash
题目以及解法思路答案在原网页上都有。https://leetcode.com/problems/count-primes/Description:Count the number of prime numbers less than a non-negative number, n.Hint:Let's start with a isPrime function.原创 2016-12-08 20:03:58 · 393 阅读 · 0 评论 -
Min Stack_栈_保存最小值(用数组)
题目:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- G原创 2016-12-09 20:25:18 · 394 阅读 · 0 评论 -
LeetCode Maximum Product Subarray_DP_最大子数组
题目:Maximum Product SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3,-2,4],the contig原创 2017-01-07 16:07:17 · 400 阅读 · 0 评论 -
416. Partition Equal Subset Sum子数组和问题
相同子集和分割。与0-1背包相似:01背包(1)、01背包(2)。问题:Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets转载 2017-02-13 22:10:30 · 1262 阅读 · 2 评论 -
494. Target Sum-回溯法、DP。
可以使用方法:回溯法、DP。相近的问题:Partition Equal Subset Sum、01背包(1)、01背包(2)。问题描述:You are given a list of non-negative integers, a1, a2, ..., an, and a target,S. Now you have 2 symbols + and -. For ea原创 2017-02-13 22:30:49 · 2015 阅读 · 0 评论