28. 实现strStr() leetcode

28. 实现strStr() leetcode_第1张图片
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]
    }
}

你可能感兴趣的:(28. 实现strStr() leetcode)