1. 二进制中1的个数:n=n&(n-1) 会把n中的最右边的1变为0;0011&0001=0001
2. 小顶堆升序,大顶堆降序
3. Given “pwwkew”, the answer is “wke”, with the length of 3. Note that the answer must be a substring, “pwke” is a subsequence and not a substring. 子序列可以不连续,子串必须连续
4. Search in rotate array 或 search insert position 都是二分查找
本文介绍了二进制中1的个数计算方法、小顶堆与大顶堆的排序方式、字符串子串与子序列的区别以及两种常见的二分查找算法应用场景。通过这些实用的算法技巧,读者可以更好地理解和掌握数据结构与算法的基础知识。
172万+

被折叠的 条评论
为什么被折叠?



