문제로

내가 푼 것

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
class Solution {
    public int strStr(String haystack, String needle) {

        for(int i = 0; i <= haystack.length() - needle.length(); i++) {
            String temp = haystack.substring(i, i + needle.length());
            if(temp.equals(needle)) return i;
        }

        return -1;
    }
}

처음으로 Submit 한 번에 통과했다