首页 > 其他 > 详细

[leetcode]Implement strStr()

时间:2014-10-30 09:31:40      阅读:162      评论:0      收藏:0      [点我收藏+]

问题描述:

Implement strStr().

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



代码:

public class Implement_strStr {  //java
	public 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);
    }
}


[leetcode]Implement strStr()

原文:http://blog.csdn.net/chenlei0630/article/details/40614525

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!