28. Implement strStr() LeetCode

来源:互联网 发布:我们来了网络几点更新 编辑:程序博客网 时间:2024/05/06 08:22

题意:实现查询一个字符串是否是另一个字符串的子串。
题解:直接用string的api了。

class Solution {public:    int strStr(string haystack, string needle) {        if(haystack.find(needle) == string::npos) return -1;        else return haystack.find(needle);    }};
0 0
原创粉丝点击