|
On
xeo →
Seeking Efficient Approach to Find Pivot in Rotated Sorted Array with Duplicates, 7 months ago
0
Oh, I see the intuition now, why it's impossible in less than O(n). Thanks! |
|
0
Case : Answer : (51 + 51) + (0 + 100) — (0 + 0 + 51 + 50) = 101 But the optimal answer : 100 (segment 1 & 3) + 99 (segment 2 & 4) = 199 |
|
0
That's actual very neat. Though I didn't understand, this implicitly force the set that supplies the pairwise min-lefts (R : rest) to be the complement of the set that supplies the pairwise max-rights (C : chosen segments). But that is not true: in a pair, the same segment can be both the min-left and the max-right. I get the solution through above formulas. But intuitively unable to picture it. |