從傳入參數 haystack 中找出參數 needle 中的索引位置,非常基礎的一題
我的答案
public class Solution {
public int StrStr(string haystack, string needle) {
if(needle == null || needle == string.Empty){
return 0;
} else if(haystack == null){
return -1;
}
return haystack.IndexOf(needle);
}
}