rewrite leetcode sqrt