You are viewing a single comment's thread. Return to all comments →
My Java Solution:
public static void separateNumbers(String s) { // Write your code here for(int i = 1; i <= s.length()/2; i++) {
long firstNumber = Long.parseLong(s.substring(0, i)); long currentNumber = firstNumber; StringBuilder shot = new StringBuilder(); shot.append(currentNumber); while(shot.length() < s.length()){ currentNumber++; shot.append(currentNumber); } if(s.equals(shot.toString())) { System.out.println("YES " + firstNumber); return; } } System.out.println("NO"); }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Separate the Numbers
You are viewing a single comment's thread. Return to all comments →
My Java Solution:
public static void separateNumbers(String s) { // Write your code here for(int i = 1; i <= s.length()/2; i++) {
}