由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 请教一个题 string similarity
相关主题
问一道interview street 上的题一道Twitter面经题,求问我的答案对不对
问一道算法题贴一下我google第一轮店面的题目
给大家推荐个网站,interviewstreet.com还真从来没见过考KMP之类string matching算法的
贡献个设计题请教suffix array的问题
Leetcode Scramble String简单解法Longest common string问题
问道题: numbers of distinct substring问几道较难的字符串题
HackerRank find string..finds all repeated substrings in the string --- YAHOO interview question
问道看到的面试题最长回文串
相关话题的讨论汇总
话题: 34话题: similarity话题: string话题: strings话题: ababaa
进入JobHunting版参与讨论
1 (共1页)
a**********0
发帖数: 422
1
For two strings A and B, we define the similarity of the strings to be the
length of the longest prefix common to both strings. For example, the
similarity of strings "abc" and "abd" is 2, while the
similarity of strings "aaa" and "aaab" is 3.
Calculate the sum of similarities of a string S with each of it's
suffixes.
Input:
The first line contains the number of test cases T. Each of the next T lines
contains a string each.
Output:
Output T lines containing the answer for the corresponding test case.
Constraints:
1 <= T <= 10
The length of each string is at most 100000 and contains only lower case
characters.
Sample Input:
2
ababaa
aa
Sample Output:
11
3
Explanation:
For the first case, the suffixes of the string are "ababaa", "
babaa", "abaa", "baa", "aa" and "a". The
similarities of these strings with the string "ababaa" are 6,0,3,0,
1, & 1 respectively. Thus, the answer is 6 + 0 + 3 + 0 + 1 + 1 = 11.
For the second case, the answer is 2 + 1 = 3.
a**********0
发帖数: 422
2
继续等待大家的思路
a**********0
发帖数: 422
3
这个题挺简单的 想出来了 当初脑子短路
s********d
发帖数: 93
4
能说说思路吗?
1 (共1页)
进入JobHunting版参与讨论
相关主题
最长回文串Leetcode Scramble String简单解法
请教:string pattern match 题问道题: numbers of distinct substring
用suffix tree 实现从string中找某些substring的算法 ?HackerRank find string..
问一个很简单的suffix tree问题。请指点。问道看到的面试题
问一道interview street 上的题一道Twitter面经题,求问我的答案对不对
问一道算法题贴一下我google第一轮店面的题目
给大家推荐个网站,interviewstreet.com还真从来没见过考KMP之类string matching算法的
贡献个设计题请教suffix array的问题
相关话题的讨论汇总
话题: 34话题: similarity话题: string话题: strings话题: ababaa