class Solution {
    public int strStr(String haystack, String needle) {
        int lengthA = haystack.length();
        int lengthB = needle.length();
        if(lengthB > lengthA) {
            return -1;
        }
        for(int i = 0; i + lengthB - 1 < lengthA;i++) {
            boolean bFound = true;
            for(int k = i, j = 0; j < lengthB;j++, k++) {
                if(haystack.charAt(k) != needle.charAt(j)) {
                    bFound = false;
                    break;
                }    
            }
            if(bFound) {
                return i;
            }
        }
        return -1;
    }
}
