error:
cannot slove it.
- Use two heap, first the keep store left half and other for right heap. And
0 <= |left.size() - right| <= 1
. If violent the rule, move to top number to other side. If current num larger than left.top(), push to right, otherwise push to left. - Use BST, and multiset is implement of BST. We have 4 case:
odd -> even
- num < r: l–
- num >= r: r++
even ->odd - num < r: r–, l = r
- num >= r: l = r