给一个无序数组,统计数组中 a[i]+a[j]>某个 k,且 i<j 的对数,要求时间复杂度小于 nlogn
1 | function countPairs(arr, k) { |
如何判断两个单向链表是否有交点,除了哈希表保存全部节点值
- 首先计算出 A,B 链表的长度
- 将指针指向 A,B 相同长度的未知
- 遍历一遍,找到第一个相交的点?有的话说明有交点,否则没有
If you like this blog or find it useful for you, you are welcome to comment on it. You are also welcome to share this blog, so that more people can participate in it. If the images used in the blog infringe your copyright, please contact the author to delete them. Thank you !