由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 一个code challenge
相关主题
突然想到一个关于string matching的题攒人品,twitter电话面经
这个怎么做?问道老题
cloudera的codebility的 test关于KMP里pre-process table的里的fall back
微软电面f电面面筋,
攒rp整理面试题(1)string match/text search有人同看Longest Palindromic Substring 这道题么?
查找substr的问题求问FB题目
amazon 两轮电面Leetcode的题能看到test cases么?
google interview question小公司面经
相关话题的讨论汇总
话题: dna话题: output话题: virus话题: matching话题: substrings
进入JobHunting版参与讨论
1 (共1页)
b*******d
发帖数: 750
1
一个公司发的。感觉不容易。
-------------------------
Save Humanity(30points)
Oh!! The mankind is in trouble again.This time its a deadly disease
spreading with rate never seen before. Efficient detectors for the virus
responsible is the need of hour. You being the lead at Central Hospital need
to find a fast and reliable way to detect the 'foot-prints' of virus DNA in
that of patient.
The DNA of patient as well as of virus consist of lower case letters. Since
the data collected is raw there might be some errors.So you need to find all
substrings in the patient DNA that exactly matches the virus DNA with
exception of one at most one mismatch.
For example tolerating at most one mismatch, "aa" and "aa" are matching, "ab
" and "aa" are matching, while "ab" and "ba" are not.
Input:
The first line contains the number of test cases T. T cases follow. Each
case contains two lines containing strings P(Patient DNA) and V(Virus DNA) .
Each case is followed by a blank line.
Output:
Output T lines, one corresponding to each case. For each case, output a
space delimited list of starting indices (0 indexed) of substrings of P
which are matching with V according to the condition mentioned above . The
indices has to be in increasing order.
Constraints:
1 <= T <= 10
P and V contain at most 100000 characters each.
All characters in P and V are lowercase letters.
Sample Input:
3
abbab
ba
hello
world
banana
nan
Sample Output:
1 2
0 2
Explanation:
For the first case, the substrings of P starting at indices 1 and 2 are "bb"
and "ba" and they are matching with the string V which is "ba".
For the second case, there are no matching substrings so the output is a
blank line.
Download sample testcases as zip ['Compile & Test' will run your code
against these testcases. Avoid using Notepad for viewing these testcases]
d******b
发帖数: 73
2
解决这个问题不难,难的是一个高效的算法。
b*******d
发帖数: 750
3

yes, I did some tricks but still several big tests can't pass.

【在 d******b 的大作中提到】
: 解决这个问题不难,难的是一个高效的算法。
d*******l
发帖数: 338
b***e
发帖数: 1419
5
对于每一个V和P,求V和reverse(V)的KMP。然后用KMP(V)从前向后扫一遍P,用KMP(
reverse(V))从后向前扫一遍P,几下所有partial match的起始。组后扫一遍所有
partial matches,看有没有能在一个点对上并且长度合适的。这样整个的算法是线性
的。

【在 b*******d 的大作中提到】
:
: yes, I did some tricks but still several big tests can't pass.

1 (共1页)
进入JobHunting版参与讨论
相关主题
小公司面经攒rp整理面试题(1)string match/text search
昨天做online test, 又来一个傻逼分数,查找substr的问题
问一道算法题max length of subsequence string matching subsamazon 两轮电面
一个Google面试题google interview question
突然想到一个关于string matching的题攒人品,twitter电话面经
这个怎么做?问道老题
cloudera的codebility的 test关于KMP里pre-process table的里的fall back
微软电面f电面面筋,
相关话题的讨论汇总
话题: dna话题: output话题: virus话题: matching话题: substrings