Short Answer


  • 0
    Y
        public int strStr(String h, String n) {
            if(h.length()==0 && n.length()==0)
                return 0;
            for(int i=0; i<h.length(); i++)
                if(i+n.length() <= h.length() && h.substring(i, i+n.length()).equals(n))
                    return i;
            return -1;
        }
    }

Log in to reply
 

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