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