摘要: 问题描述: 数据结构之并查集 问题解决: (1)概述 并查集是一种树型的数据结构,用于处理一些不相交集合(Disjoint Sets)的合并及查询问题。常常在使用中以森林来表示。 进行快速规整。 (2)基本操作 合并两个不相交集合 判断两个元素是否属于同一集合 主要操作的解释及代码 需要注意的是,一开始我... 阅读全文
posted @ 2013-08-09 10:10 罗松超 阅读(432) 评论(0) 推荐(0) 编辑
摘要: 问题描述: 后缀树(Suffix Tree) 参考资料: http://www.cppblog.com/yuyang7/archive/2009/03/29/78252.html http://blog.csdn.net/v_july_v/article/details/6897097 简介 后缀树是一种PAT树,它描述了给定字符串... 阅读全文
posted @ 2013-08-09 10:07 罗松超 阅读(15021) 评论(0) 推荐(1) 编辑
摘要: 题目 原文: Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isS... 阅读全文
posted @ 2013-08-09 10:05 罗松超 阅读(688) 评论(0) 推荐(0) 编辑
摘要: 题目 原文: Write a method to replace all spaces in a string with ‘%20’. 译文: 写一个函数,把字符串中所有的空格替换为%20 。 解答 简单题。先遍历一次字符串,得到空格个数,进而得到将空格转换成%20后的串长度 (每个空格替换为%20需要增加2个字符,x个空格增加2x个字符)。 然后从后向前依次对空格进行替换,非空格原样... 阅读全文
posted @ 2013-08-09 10:04 罗松超 阅读(1872) 评论(0) 推荐(0) 编辑