2020 第 13 周 LeetCode 记录

Yiran at 
1387. Sort Integers by The Power Value 链接到标题 给定一个区间,让你求出这个区间内所有数字的权重,然后按照权重进行排序,权重计算方式为:如果 x 是偶数,那么 x = x / 2 如果 x 是奇数,那么 x = 3 * x + 1 在计算过程中,肯定会有重复计算,所以使用 dict 记录已经计算过的数值权重。当计算完成后,对结果进行排序,优先使用权重排序,如果权重相同,则按照数值本身大小进行排序,取第 k 个。class Solution(object): def getKth(self, lo, hi, k): """ :type lo: int :t……