import java.util.*; class Algorithm { public int[] algorithm(int Num) { return Arrays.stream( Integer .toBinaryString(Num) // turn to binary .replaceAll("(^0+|0+$)", "") // remove the requences which are not between the caracter .split("1")) // create a array where each value is the zeros sequences .map(String::length) // create a map with the length of each sequence .reduce(0, Integer::max); // return the max value found } }