fork download
  1. public class Main {
  2. public static void main(String[] args) {
  3. String s = "a3";
  4.  
  5. char lastLetter = 0;
  6. boolean isDigit = false;
  7. int digit = 0;
  8. for(int i = 0; i <= s.length(); i++) {
  9. char c = i != s.length() ? s.charAt(i) : 0;
  10.  
  11. if(Character.isDigit(c)) {
  12. isDigit = true;
  13. digit = digit*10 + (c-'0');
  14. continue;
  15. }
  16. if(isDigit) {
  17. for(int j = 0; j < digit-1; j++) {
  18. System.out.print(lastLetter);
  19. }
  20. isDigit = false;
  21. digit = 0;
  22. }
  23. System.out.print(lastLetter);
  24. lastLetter = c;
  25. }
  26. }
  27. }
Success #stdin #stdout 0.1s 320512KB
stdin
Standard input is empty
stdout
aaa