码迷,mamicode.com
首页 >  
搜索关键字:algorithm    ( 11758个结果
[LeetCode] Interleaving String [30]
题目:交差字符串。给3个字符串s1, s2, s3,判断s3是不是由s1和s2组成的交叉字符串。 设s1长度为m, s2长度为n,判断 s3[0...m+n-1] 是不是由s1[0...m-1], s2[0...n-1]组成的交叉字符串,假设s1[m-1] == s3[m+n-1],则只需判断s3[0...m+n-2]是不是由s1[0...m-2], s2[0...n-1]组成的交叉字符串...,依次这样判断下去。从这可以总结,这个问题可以划分为比它小的问题,这里使用动态规划应该比较合适。 dp[i][j]...
分类:其他好文   时间:2014-06-16 12:38:58    阅读次数:166
删除一个字符串中连续超过一次的空格
问题 删除一个字符串中连续超过一次的空格。 解决(Python) #! /usr/bin/env python #coding:utf-8 def del_space(string): split_string = string.split(" ") #以空格为分割,生成list,list中如果含有空格,则该空格是连续空格中的后一个 string_list =...
分类:其他好文   时间:2014-06-16 11:21:52    阅读次数:204
[LeetCode] [First Missing Positive 2012-03-08]
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 s...
分类:其他好文   时间:2014-06-13 20:25:38    阅读次数:241
算法绪论
1.什么是算法?正确、确定、可行、有穷的过程。2.什么是好的算法?a.正确(语法正确,编译连接,正确处理任意合法输入)b.健壮(处理不合法输入) c.可读 d.效率
分类:其他好文   时间:2014-06-13 15:56:48    阅读次数:209
【Algorithm】冒泡排序
一. 算法描述 冒泡排序思想:依次比较相邻的数据,将小数据放在前,大数据放在后;即第一趟先比较第1个和第2个数,大数在后,小数在前,再比较第2个数与第3个数,大数在后,小数在前,以此类推则将最大的数"滚动"到最后一个位置;第二趟则将次大的数滚动到倒数第二个位置......第n-1(n为无序数据的个....
分类:其他好文   时间:2014-06-13 15:51:42    阅读次数:207
[Leetcode] First Missing Positive
Questions:Given an unsorted integer array, find the first missing positive integer.For example,Given[1,2,0]return3,and[3,4,-1,1]return2.Your algorithm...
分类:其他好文   时间:2014-06-13 13:16:42    阅读次数:205
Depth-first Search(DFS)
There are generally two methods to write DFS algorithm, one is using recursion, another one is using stack. (reference from Wiki Pedia)Pseudocode for ...
分类:其他好文   时间:2014-06-13 08:39:34    阅读次数:218
[Leetcode] Best Time to Buy and Sell Stock III
Question:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may c...
分类:其他好文   时间:2014-06-12 19:55:05    阅读次数:292
[LeetCode] Rotate Image [26]
题目:... 解题思路: 顺时针方向旋转数组90°。这个题也是个没啥意思的题,自己画画图,找找规律。就出来了。我举一个n=4的例子还说明下规律: 通过图可以看出A[0][0] = A[3][0],....。从这些中我们可以找到如下规律: A[i][j] = A[n-1-j][i]; A[n-1-j][i] = A[n-1-i][n-1-j]; A[n-1-i][n-1-j] = A[j][n-1-i]; A[j][n-1-i] = A[i][j];(原来的A[i][j...
分类:其他好文   时间:2014-06-10 18:09:47    阅读次数:281
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!