code-字符串
文章平均质量分 75
chunxia75qin
这个作者很懒,什么都没留下…
展开
-
Restore IP Addresses
题目:Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Ord原创 2013-05-30 12:36:39 · 676 阅读 · 0 评论 -
sizeof 与strlen的区别
sizeof 与strlen的区别: 1.sizeof操作符的结果类型是size_t,它在头文件中typedef为unsigned int类型。该类型保证能容纳实现所建立的最大对象的字节大小。 2.sizeof是算符,strlen是函数。 3.sizeof可以用类型做参数,strlen只能用char*做参数,且必须是以''\0''结尾的。sizeof还可以用函数做参数,比如:sh原创 2013-09-16 10:47:13 · 455 阅读 · 0 评论 -
strcpy、memcpy与memmove的实现
1、定义函数: void *memcpy(void *dest, const void *src, size_t n)函数说明: memcpy()用来拷贝src所指的内存内容前n个字节到dest所指的内存地址上。 与strcpy()不同的是,memcpy()会完整的复制n个字节,不会因为遇到字符串结束'\0'而结束。memcpy与memmove的原创 2013-09-16 10:41:06 · 540 阅读 · 0 评论 -
最长递增子序列、最长公共子串、最长公共子序列、字符串编辑距离
最长递增子序列:解法1:很明显用动态规划的算法,选取下面的阶段(这种选法极为常见),可使阶段间的关系具有无后效性。阶段:在所有以元素k结尾的子数组中,选出其中的最长递增子序列,k=1,2...n。状态:以元素k结尾的最长递增子序列中只有一个最长的递增子序列。决策:决定元素k结尾的最长递增子序列有k-1种获取的途径,前面以任何一个元素结尾的最长递增子序列都可能成为其的一部分。原创 2013-09-07 18:58:32 · 835 阅读 · 2 评论 -
KMP算法
作者:July。出处:http://blog.csdn.net/v_JULY_v/。引记 此前一天,一位MS的朋友邀我一起去与他讨论快速排序,红黑树,字典树,B树、后缀树,包括KMP算法,唯独在讲解KMP算法的时候,言语磕磕碰碰,我想,原因有二:1、博客内的东西不常回顾,忘了不少;2、便是我对KMP算法的理解还不够彻底,自不用说讲解自如,运用自如了。所以,特再写本篇文章。由于转载 2013-09-07 11:08:26 · 597 阅读 · 0 评论 -
Longest Palindromic Substring
题目:Given a string S, find the longest palindromic substring in S.即给出一个字符串S,找到一个最长的连续回文串。例如串 babcbabcbaccba 最长回文是:abcbabcba分析:首先将输入字符串S, 转换成一个特殊字符串T,转换的原则就是将S的开头结尾以及每两个相邻的字符之间加入一个特殊的字符,例如#原创 2013-08-07 13:11:52 · 533 阅读 · 0 评论 -
Longest Substring Without Repeating Characters
题目: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.原创 2013-07-25 16:42:54 · 577 阅读 · 0 评论 -
Valid Palindrome
题目:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is n原创 2013-06-06 10:27:00 · 381 阅读 · 0 评论 -
Scramble String
题目:Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "great": great / \原创 2013-05-28 13:05:34 · 395 阅读 · 0 评论 -
Decode Ways
题目:A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total原创 2013-05-28 14:54:21 · 585 阅读 · 0 评论 -
Distinct Subsequences
题目:Given a string S and a string T, count the number of distinct subsequences ofT in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can原创 2013-06-04 13:25:52 · 610 阅读 · 0 评论 -
Interleaving String
题目:Given s1, s2, s3, find whether s3 is formed by the interleaving ofs1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc",原创 2013-05-30 14:58:40 · 721 阅读 · 0 评论 -
简化仅由a,b,c 3种小写字母组成的字符串
题目详情:给定一个字符串,仅由a,b,c 3种小写字母组成。 当出现连续两个不同的字母时,你可以用另外一个字母替换它,如 有ab或ba连续出现,你把它们替换为字母c; 有ac或ca连续出现时,你可以把它们替换为字母b; 有bc或cb 连续出现时,你可以把它们替换为字母a。 你可以不断反复按照这个规则进行替换,你的目标是使得最终结果所得到的字符串尽可能原创 2013-09-10 10:43:19 · 2184 阅读 · 8 评论