28.|28. 实现strStr() leetcode

28.|28. 实现strStr() leetcode
文章图片
image.png

class Solution { func strStr(_ haystack: String, _ needle: String) -> Int { if needle.count == 0 { return 0; }else if needle.count > haystack.count{ return -1 } if haystack.contains(needle){ for i in 0..Character?{ if index >= self.count || index < 0{ return nil } let i = self.index(self.startIndex, offsetBy:index) return self[i] } }

    推荐阅读