Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 spaceseparated 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 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 odes 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'aseDESCRIPTION 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 abc asd ase cba esa dsa Sample Output
abcc; Sample Input
bot boot tob toob Sample Output
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started