知识点
字符串查找
思路
把words中的字符串拼接起来,在原串中查找即可。
AC Code(C++)
#include <numeric>
class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param s string字符串
* @param words string字符串vector
* @return int整型
*/
int findLongestSubstring(string s, vector<string>& words) {
return s.find(accumulate(words.begin(), words.end(), string()));
}
};

京公网安备 11010502036488号