由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 献码:Repeated DNA Sequences
相关主题
问一下Repeated DNA Sequences求DEBUG Substring with Concatenation of All Words
G家店电面挂,在不面他家了,坑太深请教leetcode上的count and say
请教一个新鲜算法面试题leetcode online judge Longest Palindromic Substring memory limit exceeded
问几道面试题Bloomberg电面题目+ 攒RP for onsite
请教一道 G 家 DNA edit distance的题ZigZag 又读不懂题了,求助!
please DIscuss Two similar alg questions Memory Limit Exceeded: Longest Palindromic Substring
给大家推荐个网站,interviewstreet.comleetcode上zigzag converstion那题怎么才能通过large?
上一道题Time limit exceeded for Word Ladder(leetcode)
相关话题的讨论汇总
话题: ss话题: return话题: string话题: map话题: toint
进入JobHunting版参与讨论
1 (共1页)
a*********0
发帖数: 2727
1
class Solution {
public:
vector findRepeatedDnaSequences(string s) {
int map[4];
std::fill(map, map+4, 0);
vector res;
set keySet;
multimap mmap;
if(s.size()<10) return res;

for(int i=0;i map[toInt(s[i])]++;
if(i>=9){
if(i>=10){
map[toInt(s[i-10])]--;
}
string ss=toString(map);
keySet.insert(ss);
mmap.insert(make_pair(ss, i));
}
}
for(auto key: keySet){
if(mmap.count(key)>1){
auto ret=mmap.equal_range(key);
for(auto i=ret.first; i!=ret.second; i++){
res.push_back(s.substr(i->second-9, 10));
}
}
}
return res;
}
int toInt(char c){
switch(c){
case 'A': return 0;
case 'C': return 1;
case 'G': return 2;
case 'T': return 3;
}
return 4;
}
std::string toString(int a[]){
std::stringstream ss;
ss << 'A' << a[0];
ss << 'C' << a[1];
ss << 'G' << a[2];
ss << 'T' << a[3];
return ss.str();
}
};
Output Limit Exceeded:怎么破?
1 (共1页)
进入JobHunting版参与讨论
相关主题
Time limit exceeded for Word Ladder(leetcode)请教一道 G 家 DNA edit distance的题
IF语句&&前后换个顺序就超时!!!搞笑啊!!!please DIscuss Two similar alg questions
请教 怎样存下这个string给大家推荐个网站,interviewstreet.com
L一个电面题上一道题
问一下Repeated DNA Sequences求DEBUG Substring with Concatenation of All Words
G家店电面挂,在不面他家了,坑太深请教leetcode上的count and say
请教一个新鲜算法面试题leetcode online judge Longest Palindromic Substring memory limit exceeded
问几道面试题Bloomberg电面题目+ 攒RP for onsite
相关话题的讨论汇总
话题: ss话题: return话题: string话题: map话题: toint