04 2021 档案

摘要:本文将分析put(),resize(),get()和remove()方法的源码 putval()方法 大致步骤:计算key的hash值;根据hash值计算数组下标;判断下标处是否有节点,无节点则直接插入,有则根据是链表还是红黑树进行对应操作。 这里需要注意的是如果插入链表后长度达到了8,且table 阅读全文
posted @ 2021-04-29 18:57 凝冰物语 阅读(85) 评论(0) 推荐(0)
摘要:比如外存中有100G的字符串文件,1G的内存,对字符串进行排序操作。 1.首先将100G的内容分成若干个小部分,每个部分不超过500MB。分别读取这些小部分进行排序,然后写入到外存中。这样就得到了若干个已经排好序的小部分。 2.多路归并排序,(相对二路归并而言)。对于k个已经排好序的小部分,每次取出 阅读全文
posted @ 2021-04-12 23:23 凝冰物语 阅读(1657) 评论(0) 推荐(0)
摘要:Description 给定数组arr和整数num,求arr的连续子数组中满足:其最大值减去最小值的结果大于num的个数。请实现一个时间复杂度为O(length(arr))的算法。 Input 输入第一行为测试用例个数。每一个用例有若干行,第一行为数组,每一个数用空格隔开,第二行为num。 Outp 阅读全文
posted @ 2021-04-08 23:14 凝冰物语 阅读(270) 评论(0) 推荐(0)
摘要:Description 给定一个整型数组arr和一个大小为w的窗口,窗口从数组最左边滑动到最右边,每次向右滑动一个位置,求出每一次滑动时窗口内最大元素的和。 Input 输入第一行为用例个数, 每个测试用例输入的第一行为数组,每一个元素使用空格隔开;第二行为窗口大小。 Output 输出每个测试用例 阅读全文
posted @ 2021-04-08 22:18 凝冰物语 阅读(102) 评论(0) 推荐(0)
摘要:Description Given a square grid of size n, each cell of which contains integer cost which represents a cost to traverse through that cell, we need to 阅读全文
posted @ 2021-04-08 00:40 凝冰物语 阅读(118) 评论(0) 推荐(0)
摘要:Description Rahul and Ankit are the only two waiters in Royal Restaurant. Today, the restaurant received N orders. The amount of tips may differ when 阅读全文
posted @ 2021-04-05 00:01 凝冰物语 阅读(128) 评论(0) 推荐(0)
摘要:Description Mike is a lawyer with the gift of photographic memory. He is so good with it that he can tell you all the numbers on a sheet of paper by h 阅读全文
posted @ 2021-04-05 00:00 凝冰物语 阅读(98) 评论(0) 推荐(0)