随笔分类 - Algorithms
摘要:How would you design a URL shortening service that is similar to TinyURL? Background:TinyURL is a URL shortening service where you enter a URL such as
阅读全文
摘要:这篇小结主要是参考这篇帖子从头到尾彻底理解KMP,不得不佩服原作者,写的真是太详尽了,让博主产生了一种读学术论文的错觉。后来发现原作者是写书的,不由得更加敬佩了。博主不才,尝试着简化一些原帖子的内容,希望能更通俗易懂一些。博主的帖子一贯秉持通俗易懂的风格,使得非CS专业的人士也能读懂,至少博主自己是
阅读全文
摘要:二分查找法作为一种常见的查找方法,将原本是线性时间提升到了对数时间范围,大大缩短了搜索时间,具有很大的应用场景,而在 LeetCode 中,要运用二分搜索法来解的题目也有很多,但是实际上二分查找法的查找目标有很多种,而且在细节写法也有一些变化。之前有网友留言希望博主能针对二分查找法的具体写法做个总结
阅读全文
摘要:Chapter 1. Arrays and Strings 1.1 Unique Characters of a String 1.2 Reverse String 1.3 Permutation String 1.4 Replace Spaces 1.5 Compress String 1.6 R
阅读全文
摘要:DescriptionIn the city, there is a one-way straight highway starts from the northern end, traverses the whole city southward, and finishes at the sout...
阅读全文
摘要:这个马拉车算法 Manacher‘s Algorithm 是用来查找一个字符串的最长回文子串的线性方法,由一个叫 Manacher 的人在 1975 年发明的,这个方法的最大贡献是在于将时间复杂度提升到了线性,这是非常了不起的。对于回文串想必大家都不陌生,就是正读反读都一样的字符串,比如 "bob"
阅读全文
摘要:这是Combinations 组合项的延伸,在这里,我们允许不同的顺序出现,那么新的题目要求如下:Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4...
阅读全文
摘要:以下转换代码摘自维基百科 Wikipedia:/* The purpose of this function is to convert an unsigned binary number to reflected binary Gray code. Th...
阅读全文