摘要:
描述: Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two 阅读全文
摘要:
描述: There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexit 阅读全文
摘要:
描述: 给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。如果你最多只允许完成一笔交易(即买入和卖出一支股票),设计一个算法来计算你所能获取的最大利润。注意你不能在买入股票前卖出股票。 解答: 首先我们可以想到的使用暴力的方法,计算出每天买入和卖出股票所能够获得的最大的收益,找出所有收 阅读全文