What's wrong with the code

Although method signature is different output is same except the order of strings in the arraylist …

@Narasimha,
https://ide.codingblocks.com/s/222718 correct code.

Your code is also correct but we need to write code according to the question requirement. Here we do not need arraylist to store our answer.