摘要:
用heap解, 方法1. 维护一个 size = k 的最小堆。当前元如果大于堆顶的元素,那么说明堆顶的元素肯定小于kth largest element。所以replace他。 或者维护一个-nums的最小堆,从heap pop出第k个元素。那么这个数就是 -nums的第k小元素,也就是nums的 阅读全文
摘要:
class Solution(object): def multiply(self, num1, num2): """ :type num1: str :type num2: str :rtype: str """ n1 = len(num1) n2 ... 阅读全文
摘要:
Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction 阅读全文