Implement strStr().
Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
偷懒用了现成的函数;indexOf
源码链接:
点击打开链接
本文介绍了如何实现strStr()函数,该函数用于返回needle在haystack中首次出现的索引,若needle不是haystack的一部分则返回-1。作者在实现过程中使用了现成的indexOf函数。
Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.

被折叠的 条评论
为什么被折叠?