Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Code java optimize Consider the following: A non - empty array, inarr of strings containing only lowercase alphabets Am 2 matrix of integers inmatrix
Code java optimize Consider the following:
A nonempty array, inarr of strings containing only lowercase alphabets
Am matrix of integers inmatrix tablepips"sis'
The number of consonants in each of the replaced elements are:
tableinarrafter replacement# of consonants,outstrapple"guava"guavapomegranatesis
Ingort jave.util.
ciass midede
System.out
such that:
the size of inarr is equal to
the elements of inarr and the rows of inmatrix have onetoone correspondence
each row of integers vec and vec of inmatrix would be such that
is always less than the length of the corresponding string in inarr
would always be less than inarr:
"apphe"
"goava"
"pomegranate"
"pip"
inmatrix:
import
java.util.
class mivCode
Perform the following operations:
For each string str in inarr and corresponding row of integers and of inmatrix, replace all the occurrences of the character at th index in str with the th element in the alphabet series Note: alphabet series would be the element and would be the element
Starting from leftmost replaced string from inarr, identify the first string with the minimum number of consonants and assignStarting from leftmost replaced string from inarr, identify the first string with the minimum number of consonants and assign it to outStr
Print outStr
Input Format:
First line contains inarr, with the elements separated by :comma
Second line will contain number of rows of inmatrix
The next lines will contain the elements of inmatrix. Each line will have elements separated by space.
Read the inputs from the standard input stream.
Output Format:Output Format:
Print outstr to the standard output stream
Sample inputs and outputs:
Sample Input:
apphe,goava,pomegranate, pip
Sample Output:
guava
Explanation:
i
java.util.:
class
UCode
public stataic
xplanation:
tabletableinarrinitialvalueinmatrix values,tablevalue atindexinmatrixjtablecharacterininarr tobereplacedtablecharacterto bereplacedtableinarrafterreplacemerappheI,"apple"goavao"guava"oomegranateapomegranapssis"
import java.uti;
cluss
mCode
System.out. P
publif statie void
e number of consonants in each of the replaced elements are:
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