Recent Oracle Interview question - Oracle Tech Screen - String manipulation - Need better solution

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2021-10-23Added By Anonymous
Source: Link

Company: Oracle
Role: unknown
Interview Stage: Tech Screen
Location: unknown
Year: unknown

Original Post Content:

I was recently asked the below question in the Oracle Tech screen. I was able to solve it via String split function but the interviewer mentioned to change my approach and use collections which I was not able to come up with. The language used was java.

What would be a better collection/data structure way to solve the below problem:

Use case 1
Input - 2[bcbc]
Output - bcbcbcbc

Use case 2
Input - 3[a2[bdbd]]
Output - abdbdbdbdabdbdbdbdabdbdbdbd

Comments