Tony's Log

Algorithms, Distributed System, Machine Learning

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

Fancy, classic, STEP-BY-STEP Analysis strategy problem. Here is the approach:

1. Sort input arrays.. so sum[0] is a[0] * k, so we got a[0]
2. Then who is 2nd smallest? a[0] * (k-1) + a[1] - from a[0] to a[1], the strategy is pretty obvious now: we guess a[i] one by one
3. How do we guess a[i], when we have a[0]..a[i-1]? It will be the same problem after we remove all sums involving only a[0]..a[i-1]
4. Now the only problem is, how do we remove all sums involving a[0]..a[i-1]

posted on 2017-12-30 03:55  Tonix  阅读(228)  评论(0编辑  收藏  举报