An interview question I got - Given int n, find the smallest number of square numbers that fit inside n.Example:Input: 24 Output: 3 (16 + 4 + 4)Input: 10Output: 2 (9 + 1)Solution:public class Solution{    public static int solution(int number){        int squareCount = 0;        while(number> 0){            int square = (int)Math.sqrt(number);            squareCount++;            number-=square*square;        }               return squareCount;     }}Notes:Must be Java 7Must be in class called Solution, with a public static int solution(int number) methodMust not use any 3rd party librariesI like this solution because it is very simple, however it does have one inefficiency. It finds the square root only to perform a squaring operation again. It would be nice if I could find the largest square number in squared form immediately, but I cant think of an efficient way to do this. 
Find the smallest number of square numbers to create n
java;performance;interview questions