Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are working in a chemical factory. Each chemical in the factory is represented by a string. You have to group the chemicals in such

You are working in a chemical factory. Each chemical in the factory is represented by a string. You have to group the chemicals in such a way that no two explosive chemicals are together. You are given an array of size N, denoting the names of N chemicals. Let x and y be two strings representing two chemicals. Let z=x+x( For example, if x="abc"
then z="abcabc "
). The chemicals x and y are said to be explosive if we can jumble the characters of string z to get chemical y. Your task is to return the number of pairs of chemicals that are explosive. Input Specification: input1: An integer N denoting the size of the array. input2: An array of strings denoting the names of N chemicals.
Output Specification:
An integer denoting the number of pairs of chemicals that are explosive.
Example 1:
input1: 5
input2: ("hacker", "int", "niitnt", "hackhackerer", "long")
Output: 2
Example 2:input1:3input2: ('medium", "easy", "yeasseya")Output: 1
write a c++ code

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions