
字符串
bae_
趁着年轻,好好学习
展开
-
字符串反转问题
一,第一类的字符串反转问题,也就是输入This is a string.,输出为.gnirts a si sihT,整个字符串反转:void reverse1(char *a){ int len=strlen(a)-1; int i=0; while(i<len){ char ch=a[i]; a[i++]=a[len]; a[原创 2015-05-02 21:27:06 · 426 阅读 · 0 评论 -
字符串查找算法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 评论 -
ZigZag Conversion leetcode6
The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H N A P L原创 2015-05-18 00:22:19 · 253 阅读 · 0 评论 -
Multiply Strings leetcode 43
Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.经典的大数相乘问题: 1,从给定字符串最后一位开始操作,要弄清楚整个乘法的过程以及各进位的原创 2015-06-03 23:48:49 · 462 阅读 · 0 评论 -
Longest Palindromic Substring leetcode 5
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.求字符串的最长回文串1,从字符串第一个字符开始遍历,向原创 2015-05-23 13:19:56 · 301 阅读 · 0 评论 -
Longest Substring Without Repeating Characters leetcode3
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for “abcabcbb” is “abc”, which the length is 3. For “原创 2015-05-24 01:30:48 · 233 阅读 · 0 评论 -
Distinct Subsequences leetcode 115
Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of原创 2015-06-09 17:55:26 · 339 阅读 · 0 评论 -
Isomorphic Strings leetcode 205
Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with another chara原创 2015-07-02 22:25:48 · 318 阅读 · 0 评论 -
Longest Common Prefix leetcode 14
Write a function to find the longest common prefix string amongst an array of strings. 找所有字符串的公共前缀,简单地实现题class Solution {public: string strPrefix(string s1,string s2){ if(s1.length()==0||s原创 2015-06-15 18:14:44 · 305 阅读 · 0 评论