由买买提看人间百态

topics

全部话题 - 话题: strset
(共0页)
f*******w
发帖数: 1243
1
来自主题: JobHunting版 - 问大牛们一个Leetcode上的题
现在能过小case了,大的跑不过去……
class Solution {
public:
vector findSubstring(string S, vector &L) {
unordered_map strset, tmpset;
int numstr = L.size(), strlen = L[0].size();
vector ret;
for(int i = 0; i < numstr; ++i) {
auto it = strset.find(L[i]);
if(it != strset.end()) ++it->second;
else strset.insert(make_pair(L[i], 1));
}
tmpset = strset;
for(int i = 0; i < (int)S.size() - num... 阅读全帖
f*******w
发帖数: 1243
2
来自主题: JobHunting版 - 问大牛们一个Leetcode上的题
Substring with Concatenation of All Words
You are given a string, S, and a list of words, L, that are all of the same
length. Find all starting indices of substring(s) in S that is a
concatenation of each word in L exactly once and without any intervening
characters.
For example, given:
S: "barfoothefoobarman"
L: ["foo", "bar"]
You should return the indices: [0,9].
我的code如下
之前用unordered_set, 如果L里面有重复元素就跑不过
现在改用multiset, 直接出错……
求助求助……
class Solution {
public:
vector findSubstring(string ... 阅读全帖
d*****a
发帖数: 110
3
来自主题: Programming版 - c++一个问题
StrSet strSet;
//input 1000 students to strSet
string name("wangfei");
if(strSet.find(name) != strSet.end())
{
....
}
q****x
发帖数: 7404
4
来自主题: JobHunting版 - 问个简单的问题...
struct compChar {
bool operator ()(char* s1, char* s2) { return strcmp(s1, s2) < 0; }
};
set strSet;
(共0页)