码迷,mamicode.com
首页 >  
搜索关键字:leetcode palindrome    ( 35905个结果
【LeetCode】- Length of Last Word(最后一个单词的长度)
[ 问题: ] Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word does not exist, return 0. [...
分类:其他好文   时间:2014-07-22 23:01:35    阅读次数:331
4Sum -- LeetCode
原题链接: http://oj.leetcode.com/problems/4sum/  这道题要求跟3Sum差不多,只是需求扩展到四个的数字的和了。我们还是可以按照3Sum中的解法,只是在外面套一层循环,相当于求n次3Sum。我们知道3Sum的时间复杂度是O(n^2),所以如果这样解的总时间复杂度是O(n^3)。代码如下:public ArrayList> fourSum(int[] num,...
分类:其他好文   时间:2014-07-22 23:01:34    阅读次数:328
【LeetCode】- Search Insert Position(查找插入的位置)
[ 问题: ] Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in th...
分类:其他好文   时间:2014-07-22 23:01:15    阅读次数:270
UVA 10453 Make Palindrome(区间简单DP)
题意:给出一串字符串,求出需要至少插入多少个字符使得这个字符串变成会问粗...
分类:其他好文   时间:2014-05-02 23:26:33    阅读次数:486
Leetcode: Remove Elements
一次性通过的,比较顺利,从读题到编写到检查到通过,14分50秒,我在不断进步中,相信经过一段时间联系,这种题可以一眼就写出来,不超过5分钟。这道题应该说方法跟 Remove Duplicates from sorted Array挺类似的My Solution: 1 public class Sol...
分类:其他好文   时间:2014-05-02 12:56:10    阅读次数:260
LeetCode - Trangle
这道题,采用动态规划算法。from top to down,把到每个节点的最小路径和都求出来。下面是AC代码: 1 /** 2 * Given a triangle, find the minimum path sum from top to bottom. 3 * Each ...
分类:其他好文   时间:2014-05-02 12:19:23    阅读次数:382
Leetcode: Length of Last Word
许多次通过,主要是没有考虑到这种情况:“A C ”结尾有多重空格的情况。 1 public class Solution { 2 public int lengthOfLastWord(String s) { 3 int j, k; 4 if(s == nu...
分类:其他好文   时间:2014-05-02 08:21:00    阅读次数:300
Jump Game
leetcode, Jump Game , 递推求解...
分类:其他好文   时间:2014-05-02 05:10:22    阅读次数:181
[leetcode] Best Time to Buy and Sell Stock
Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie...
分类:其他好文   时间:2014-05-02 00:37:20    阅读次数:349
Leetcode:Rotate Image 旋转图片
You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in-place? 刚开始没有思路,但是自己举了几个简单的栗子才看出规律:需要一圈儿一圈儿的变换位置。有两层for循环:外...
分类:其他好文   时间:2014-05-01 18:33:34    阅读次数:359
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!