O(nlogn) Algorithm - Find three evenly spaced ones within binary string

前端 未结 30 2961
刺人心
刺人心 2020-11-28 00:07

I had this question on an Algorithms test yesterday, and I can\'t figure out the answer. It is driving me absolutely crazy, because it was worth about 40 points. I figure

30条回答
  •  再見小時候
    2020-11-28 00:57

    Wasn't able to come up with the solution yet :(, but have some ideas.

    What if we start from a reverse problem: construct a sequence with the maximum number of 1s and WITHOUT any evenly spaced trios. If you can prove the maximum number of 1s is o(n), then you can improve your estimate by iterating only through list of 1s only.

提交回复
热议问题