solution for maxPoints