Moving method getLength to Utils class because method is used in multiple problems