Question: Need solution in java In a warehouse, there is a pile consisting of N spare parts of various products. All the spare parts need to

Need solution in java In a warehouse, there is a pile consisting of N spare parts of various products. All the spare parts need to be separated and grouped based on the product they belong to. A Robot has been deployed to complete this task. Every spare part will have a code on it. Every product has only two spare parts. The spare parts that belong to a particular product will have codes that are reverse to each other. For example, the spare parts with codes abc and cba belong to the same product. Your task is to program the Robot to identify and group the spare parts. Write a program that reads a number N, the list of codes on the spare parts, and prints the list after grouping the spare parts in ascending order. The group of spare parts of a product and every product should be sorted in ascending order.The first line of input contains an integer representing The second line of input contains space-separated strings representing the codes on the spare parts. Output The output should be a single line containing a list after grouping the spare parts. Explanation For example, if the given number is N=6 and the list of codes is abc asd ase cba esa dsa ,- The codes a b c and cba are reverse to each other. So, they belong to the same product. - The codes asd and dsa are reverse to each other. So, theybelong to the same product. - Similarly, the 66odes ase and esa belong to the same product. - The sorted list after grouping the spare parts in ascending order is [['abc', 'cba'],['asd', 'dsa'],['ase', 'esa']]. The output should be [['abc', 'cba'],['asd', 'dsa'],['ase',DESCRIPTION (1) SUBMISSIONS - The sorted list after grouping the spare parts in ascending order is [['abc', 'cba'],['asd', 'dsa'],['ase', 'esa']]. The output should be [['abc', 'cba'],['asd', 'dsa'],['ase', Sample Input 16 abc asd ase cba esa dsa Sample Output 1
[[['abc','c; Sample Input 2]
4 bot boot tob toob Sample Output 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!