79091353

Date: 2024-10-15 18:52:05
Score: 0.5
Natty:
Report link

Updated working code

public String stringExpansionRegEx(String str) {

    StringBuilder result = new StringBuilder();

    boolean bool = Pattern.matches("([a-zA-Z]\\d)+", str);
    if (bool == true){
        for (int i=0;i<str.length();i+=2)  {
                 char ch = str.charAt(i);
                 int count = Integer.parseInt(String.valueOf(str.charAt(i+1)));
                 for (int j = 0; j < count; j++) {
                     result.append(ch);
                 }
        }
    }
    return result.toString();
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Urekha Rajendran