We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
My Java 8 (15) solution, feel free to ask me any questions.
privatestaticStringcreateNumericString(longstartNumber,intlenght){Stringnumeric="";longcurrent=startNumber;while(numeric.length()<lenght){numeric=numeric.concat(String.valueOf(current));current+=1;}returnnumeric;}publicstaticvoidseparateNumbers(Strings){//Maximum numbers of the first integerintmaximum=(int)Math.round(s.length()/2);for(intlenght=1;lenght<=maximum;lenght++){//Pick the first numberlongfirst=Long.valueOf(s.substring(0,lenght));//Perform checking a[i] - a[i - 1] = 1Stringnumeric=createNumericString(first,s.length());if(numeric.equals(s)){System.out.println("YES "+first);return;}}System.out.println("NO");}
Separate the Numbers
You are viewing a single comment's thread. Return to all comments →
My Java 8 (15) solution, feel free to ask me any questions.