classSolution{publicintminimumPushes(String word){int n = word.length();int res =0;int i =1;while(n /8!=0){
res +=8* i;
n -=8;
i++;}
res +=(n %8)* i;return res;}}
方法二:
classSolution{publicintminimumPushes(String word){int n = word.length();int k = n /8;return(k *4+ n %8)*(k +1);}}