字符串算法
Hello、MrTree
Hello,树先生。
展开
-
关于字符串的算法
串的模式匹配(蛮力法)lintcode字符串查找练习题#include "string.h"#include "stdio.h"char source[100],target[100];int strStr(const char *source, const char *target) { int i,j; i=j=0; if(source==N原创 2016-07-30 21:16:54 · 388 阅读 · 0 评论 -
串的模式匹配
串的模式匹配(蛮力法)lintcode字符串查找练习题#include "string.h"#include "stdio.h"char source[100],target[100];int strStr(const char *source, const char *target) { int i,j; i=j=0; if(source==N原创 2016-07-30 23:19:15 · 499 阅读 · 0 评论 -
乱序字符串算法
乱序字符串蛮力法题目链接:lintcode乱序字符串题目链接 思路等会睡醒之后写吧#include "string"#include "algorithm"#include "stdio.h"#include "iostream"#include "vector"using namespace std;bool Isanagram(string source, string tar原创 2016-07-31 01:38:40 · 754 阅读 · 0 评论 -
最长公共子串
lintcode练习题目#include "string"#include "stdio.h"#include "iostream"using namespace std;int longestCommonSubstring(string &A, string &B) { int i,j,max=0; int dp[400][400]={0};原创 2016-07-31 03:52:40 · 368 阅读 · 0 评论 -
字符串反转
#include "string"#include "stdio.h"#include "iostream"using namespace std;void myreverse(string &str,int left,int right){ while(left<right) { char temp=str[left]; str[left]原创 2016-07-31 04:29:04 · 366 阅读 · 0 评论 -
最长公共前缀
lintcode最长公共前缀class Solution {public: /** * @param strs: A list of strings * @return: The longest common prefix */ string getCommonPrefix(string source,string target) {原创 2016-07-31 14:22:52 · 415 阅读 · 0 评论 -
有效回文串
lintcode有效回文串 O(n) 时间复杂度,且不占用额外空间。class Solution {public: /** * @param s A string * @return Whether the string is a valid palindrome */ bool isAlpha(char ch) { i原创 2016-07-31 17:35:18 · 413 阅读 · 0 评论 -
LeetCode:最长回文子串
给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。示例 1:输入: "babad"输出: "bab"注意: "aba" 也是一个有效答案。示例 2:输入: "cbbd"输出: "bb" //O(n^2)解法,勉强ACclass Solution {public: string longestPalindrome(string s...原创 2019-07-24 23:02:49 · 134 阅读 · 0 评论