Page 1 of 1

write a java method to decode a given string as follows the given string will be written in the form n1[c]n2[c]

Posted: Wed Apr 27, 2022 3:12 pm
by answerhappygod
write a java method to decode a given
string as follows
the given string will be written in the
form n1[c]n2[c]
(Where n is an integer between 1 and 100, c is
any character)

Ex:
input: 3[a]4[r]2[c]

output: aaarrrrcc

The header of the method should
be

public static String decode(String
s)


Hint: to split a string using ([) or
(]) character you should write it as follows

String s1[]=s.split("\\[")