leetCode 28. Implement strStr()文字列
555 ワード
28. Implement strStr()
Implement strStr().
Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
haystackでneedleの最初の位置と一致する位置を探します.見つからない場合は、-1を返します.
コードは次のとおりです.
Implement strStr().
Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
haystackでneedleの最初の位置と一致する位置を探します.見つからない場合は、-1を返します.
コードは次のとおりです.
class Solution {
public:
int strStr(string haystack, string needle) {
if(haystack.size() == 0 && needle.size() == 0)
return 0;
if(needle.size() == 0)
return 0;
if(haystack.size()
2016-08-11 01:02:49