Answered step by step
Verified Expert Solution
Link Copied!

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 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

ISBN: 3540416641, 978-3540416647

More Books

Students also viewed these Databases questions