JAVA solution (7ms)


  • 0
    N
    class Solution {
        public int strStr(String haystack, String needle) {
            int result=0;
            if(!haystack.contains(needle)) result=-1;
            else{
                result=haystack.indexOf(needle);
            }
            return result;
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.