Tony's Log

Algorithms, Distributed System, Machine Learning

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

This is a super fun problem to think. 

Again - let's bring our ultimate tool to start playing with it - DISCRETE THINKING, STEP BY STEP.

1. [3,2] is true - global cnt 1, local cnt 1. Fine
2. [3,2,1] is False - global cnt 3, local 2. What do we get here? To have [a, b, c] to return True, a may be > b, but c has to >= a
3. Given observation at #2, only 2k, and 2k+1 (k in Integer) can be swapped  - picture it in your mind: we can only mess up with 2 consecutive numbers. So the value offset of each # can only be MAX to 1

posted on 2018-02-02 14:10  Tonix  阅读(89)  评论(0编辑  收藏  举报