class solution for partition