LeetCode
刷题代码
welding_artist
这个作者很懒,什么都没留下…
展开
-
双指针外观数列
var countAndSay = function(n) { if(n==1){ return "1"; } return explain(countAndSay(n-1)); }; function explain(num){ var str = num.toString(); let pre =0,end =0; let i = 0; let key =[];let value =[]; while(end<str原创 2020-11-12 16:51:39 · 86 阅读 · 0 评论 -
双指针寻找小字符串在长字符串出现的首次索引值
双指针寻找小字符串在长字符串出现的首次索引值 var strStr = function(haystack, needle) { var L = needle.length; var n = haystack.length; if(L === 0) return 0; var pn = 0; while(pn < n-L+1){ while(pn < n-L+1 && haystack[pn] != needle[0]) +原创 2020-11-12 11:50:30 · 106 阅读 · 0 评论