[leetcode]Implement strStr()

来源:互联网 发布:js替换所有换行符 编辑:程序博客网 时间:2024/06/06 01:52

问题描述:

Implement strStr().

Returns a pointer to the first occurrence of needle in haystack, ornull if needle is not part of haystack.



代码:

public class Implement_strStr {  //javapublic String strStr(String haystack, String needle) {if(haystack == null || needle == null)            return null;int pos = haystack.indexOf(needle);if(pos == -1)return null;return haystack.substring(pos);    }}


0 0
原创粉丝点击