class Solution {
public String dynamicName(String str) {
// Create a StringBuilder to store the dynamic name
StringBuilder sb = new StringBuilder();
// Iterate through each character in the input string
for (int i = 0; i < str.length(); i++) {
// Check if the current character is an opening parenthesis '('
if (str.charAt(i) == '(') {
// If found, iterate through characters after the opening parenthesis
for (int j = i + 1; j < str.length(); j++) {
// Check if the current character is not a closing parenthesis ')'
if (str.charAt(j) != ')') {
// Append the character to the StringBuilder
sb.append(str.charAt(j));
} else {
// If a closing parenthesis is found, exit the inner loop
break;
}
}
}
}
// Convert the StringBuilder to a String and return the dynamic name
return sb.toString();
}
}