C++ Solution to Leetcode 279. Perfect Squares