max rectangle/histogram reimpl