本文共 388 字,大约阅读时间需要 1 分钟。
给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始)。如果不存在,则返回 -1。
class Solution { public: int strStr(string haystack, string needle) { if(needle.size()==0) return 0; else if(haystack.size()==0) return -1; int i=0,j=0; while(i
通过时间:
转载地址:http://siemb.baihongyu.com/