Print the required result We need to add 1 to maxX because we cant ignore the first move where initially X = 0 and we need to increase it by 1 to make some changes in array
cout << ( maxX == 0 ? 0 : maxX + 1 ) << endl ; }