
c
文章平均质量分 56
bae_
趁着年轻,好好学习
展开
-
字符串查找算法kmp
这样一个问题:给定一个文本串s,和一个匹配串p,要求查找p第一次在s中出现的位置。 常见的方法如暴力搜素,逐个匹配s[i],p[j],若匹配,下标后移。不匹配,i回溯到这次匹配前的下一位置,j置为0,重新匹配。最坏情况,时间复杂度O(n*m)。 int violenceSearch(char *s,char *p){ int i=0,j=0; int lenp=strl原创 2015-05-03 21:22:51 · 691 阅读 · 0 评论 -
Simplify Path Leetcode71
Given an absolute path for a file (Unix-style), simplify it.For example, path = “/home/”, => “/home” path = “/a/./b/../../c/”, => “/c”click to show corner cases. Corner Cases:Did you consider the ca原创 2015-05-31 00:52:17 · 470 阅读 · 0 评论 -
HDOJ-1002大数相加
参考这篇:点击打开链接 Problem Description I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B. Input The first line of the input contains原创 2015-04-26 01:08:12 · 400 阅读 · 0 评论 -
happy number leetcode202
Write an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of i原创 2015-05-09 22:50:37 · 383 阅读 · 0 评论 -
栈的经典问题:括号配对
Parentheses Balance You are given a string consisting of parentheses () and []. A string of this type is said to be correct: (a)if it is the empty string(b)if A and B are correct,原创 2015-01-08 21:48:09 · 358 阅读 · 0 评论