由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 帮忙看看为撒 leetcode OJ time out "Substring with Concatenation of All Words "
相关主题
请教一道题目求DEBUG Substring with Concatenation of All Words
问大牛们一个Leetcode上的题Substring with Concatenation of All Words
Substring with Concatenation of All Words 还有更简洁的解法吗?关于Leetcode: Substring with Concatenation of All Words
请问Substring with Concatenation of All Words?Substring with Concatenation of All Words这题好麻烦
Leetcode第30题真心不容易LeetCode LongestValidParentheses
都来说说leetcode上无聊恶心的题吧问一道算法题max length of subsequence string matching subs
Leetcode的Substring with Concatenation of All Words超时。Dream company Onsite被搞了(少量面经)
讨论一道G的题find longest substring which contains just two unique characters.请教c++的string vector问题,谢谢!
相关话题的讨论汇总
话题: int话题: str话题: string话题: mapsrc话题: mapdest
进入JobHunting版参与讨论
1 (共1页)
c**z
发帖数: 669
1
leetcode 这道题大家帮忙看看为撒 time out
class Solution {
public:
vector findSubstring(string S, vector &L) {
// check border case
vector ret;
if ( L.empty() || S.empty() )
return ret;

int i = 0;
int j = 0;
int num = L.size();
int length = L[0].size();

map mapSrc;
map mapDest;
for( int i = 0 ; i {
mapSrc[L[i]]++;
}

i=0;

while ( ( i + num * length - 1) < S.size())
{
j = i;


while( mapDest.size() < num )
{
string str = S.substr(j, length);
if ( mapSrc.find(str) == mapSrc.end() )
{
break;
}
else
{
auto iter = mapDest.find(str);
if ( iter == mapDest.end() || mapDest[str] < mapSrc[str]
)
{
mapDest[str]++;
}
else
{
break;
}
}

j = j + length;

}

if ( mapDest.size() == num )
{
ret.push_back(i);
}

mapDest.clear();
i = i +1;
}


return ret;
}
};
P**********r
发帖数: 755
2
timeout是leetcode出错啦 你重新提交就好啦



【在 c**z 的大作中提到】
: leetcode 这道题大家帮忙看看为撒 time out
: class Solution {
: public:
: vector findSubstring(string S, vector &L) {
: // check border case
: vector ret;
: if ( L.empty() || S.empty() )
: return ret;
:
: int i = 0;

1 (共1页)
进入JobHunting版参与讨论
相关主题
请教c++的string vector问题,谢谢!Leetcode第30题真心不容易
Leetcode OJ的编译器是?都来说说leetcode上无聊恶心的题吧
leetcode online judge Longest Palindromic Substring memory limit exceededLeetcode的Substring with Concatenation of All Words超时。
leetcode 的 Insert Interval 就是过不了大的讨论一道G的题find longest substring which contains just two unique characters.
请教一道题目求DEBUG Substring with Concatenation of All Words
问大牛们一个Leetcode上的题Substring with Concatenation of All Words
Substring with Concatenation of All Words 还有更简洁的解法吗?关于Leetcode: Substring with Concatenation of All Words
请问Substring with Concatenation of All Words?Substring with Concatenation of All Words这题好麻烦
相关话题的讨论汇总
话题: int话题: str话题: string话题: mapsrc话题: mapdest