码迷,mamicode.com
首页 >  
搜索关键字:jump game ii    ( 12386个结果
Palindrome Partitioning II
题目 Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. For example, given s = "a...
分类:其他好文   时间:2014-06-20 13:44:18    阅读次数:234
[ LeetCode ] Single Number II
数组中含有n个数,其中一个数只出现1次,其余个数均出现3次,就只出现1次的数。 首先应该想到的就是计数法,先对数组排序,然后统计每个数出现的次数,找出出现次数为1个数; 更高级一点的方法还是用位运算,充分发掘数字二进制中的0和1出现的规律。一个数字是由0和1组成的,如果这个数字出现3次,那么这个数字中各个位上0和1出现的次数也应该是3次。按照这样统计数组中所有数的各个位1的个数,如果个数是1个倍数,这所求数字该位不为1。 举例如下: 数组: 1, 3, 1, 5, 1, 6, 5, 6, 6, 5 对应的...
分类:其他好文   时间:2014-06-20 12:45:44    阅读次数:185
LeetCode: Binary Tree Level Order Traversal II [107]
【题目】 Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For example: Given binary tree {3,9,20,#,#,15,7}, 3 / 9 20 / 15 7 return its b...
分类:其他好文   时间:2014-06-20 09:42:30    阅读次数:224
hust 1027 Enemy Target!
题目描述In the Game Red Alert, a group of soviet infantry marches towards our base. And we have N Prism Tanks to defend our base. Suppose the coming infan...
分类:其他好文   时间:2014-06-11 07:18:54    阅读次数:285
LeetCode: Pascal's Triangle II [119]
【题目】 Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your algorithm to use only O(k) extra space? 【题意】 给定行索引k, k从0开始,返回该索引指向的杨辉三角的行 要求只能使用O(k)的额外空间 【思路】 ...
分类:其他好文   时间:2014-06-08 15:46:02    阅读次数:272
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. ...
分类:其他好文   时间:2014-06-08 15:15:26    阅读次数:223
[LeetCode] Palindrome Partitioning II [12]
题目:For example, given s = "aab", Return 1 since the palindrome partitioning ["aa","b"] could be produced using 1 cut 解题思路:给一个字符串,如果字符串可以划分成若干子回文字符串,返回最小的划分数量。 这个题如果还用之前求所有划分组合的循环加递归方法的话,就会得到超时的错误。这是就要考虑别的方法,动态规划倒是一个不错的方法,但是动态规划最重要的是要找到动态方程。本题的动态方程: dp[i] =...
分类:其他好文   时间:2014-06-08 14:56:58    阅读次数:257
Word Break II
题目 方法...
分类:其他好文   时间:2014-06-07 15:38:42    阅读次数:143
[LeetCode] Longest Palindromic Substring [14]
最长回文字串,相信做过Palindrome Partitioning II 这个题的同学应该可以很快做出来。没错,这个题还可以使用动态规划方法得到一个时间复杂度为O(n^2)的解法,当然如果你想要更好的时间复杂度的算法也是有的。好的,我们先来看看时间复杂度为O(n^2)的算法。 代码实现--动态规划O(n^2) 相信如果你在网上看过了别人的算法,你会发现我的算法是最简洁的。哈哈,这个题需要注意的是如果你用惯了vector的话,你这里肯定会得到超时的提示... ...代码二--复杂度为O(n)的算法...
分类:其他好文   时间:2014-06-07 12:08:43    阅读次数:224
Pascal's Triangle II
Pascal's Triangle II, leetcode,两个解法...
分类:其他好文   时间:2014-06-07 11:56:29    阅读次数:138
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!