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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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("\\[")
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply