1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
san4es73 [151]
3 years ago
10

Consider an array inarr containing atleast two non-zero unique positive integers. Identify and print, outnum, the number of uniq

ue pairs that can be identified from inarr such that the two integers in the pair when concatenated, results in a palindrome. If no such pairs can be identified, print -1.Input format:Read the array inarr with the elements separated by ,Read the input from the standard input streamOutput format;Print outnum or -1 accordinglyPrint the output to the standard output stream
Computers and Technology
1 answer:
Delvig [45]3 years ago
3 0

Answer:

Program.java  

import java.util.Scanner;  

public class Program {  

   public static boolean isPalindrome(String str){

       int start = 0, end = str.length()-1;

       while (start < end){

           if(str.charAt(start) != str.charAt(end)){

               return false;

           }

           start++;

           end--;

       }

       return true;

   }  

   public static int countPalindromePairs(String[] inarr){

       int count = 0;

       for(int i=0; i<inarr.length; i++){

           for(int j=i+1; j<inarr.length; j++){

               StringBuilder sb = new StringBuilder();

               sb.append(inarr[i]).append(inarr[j]);

               if(isPalindrome(sb.toString())){

                   count++;

               }

           }

       }

       return count == 0 ? -1 : count;

   }

   public static void main(String[] args) {

       Scanner sc = new Scanner(System.in);

       String line = sc.next();

       String[] inarr = line.split(",");

       int count = countPalindromePairs(inarr);

       System.out.println("RESULT: "+count);

   }

}

Explanation:

OUTPUT:

You might be interested in
Software that was designed to serve the needs of a specific company or organization is called:
devlian [24]
<span>Basically it's software tailor made to the companies needs and the specific name for this is integrated software</span>
3 0
3 years ago
When ordering a new​ zagflatz, customers must choose the style of three major​ components, each of which has about ten variation
patriot [66]

Answer:

C. modular design

Explanation:

Based on the information provided it can be said that in this scenario being able to choose the style that you want is an example of a modular design. A modular design refers to when something is divided into various parts called modules that can be independently chosen and/or exchanged in order to create a customized object. Which is exactly what is allowed in this scenario when ordering a new zagflatz.

6 0
3 years ago
Need help with a program to search to sort elements in an array.(increasing or decreasing order)
astraxan [27]

This is for Python

numbers = [7, 3, 6, 9, 0]

print(numbers.sort())

Output: [0, 3, 6, 7, 9]

numbers = [7, 3, 6, 9, 0]

print(numbers.sort(reverse = True))

Output: [9, 7, 6, 3, 0]

7 0
3 years ago
Pendant Publishing edits multi-volume manuscripts for many authors. For each volume, they want a label that contains the author'
lbvjy [14]

Answer:

Check the explanation

Explanation:

Pseudocode For Reading File:

start

Declarations

InputFIle records.txt

OutputFile result.txt

string authorName

string title

int numOfVol

open InputFile

open OutputFile

input authorName, title, numOfVol from records.txt

while not eof

output authorName

output title

output numOfVol

end while

close records.txt

close results.txt

END

The flowchart for reading the file can be seen below.

3 0
3 years ago
What aspect should you consider before adding pictures to a document?
Luden [163]

Answer:

information?

Explanation:

picture are there to give a visual or make the document more appealing. if your wording and information isnt up to date or reasonable people wont lean to what you are saying as much.

8 0
3 years ago
Read 2 more answers
Other questions:
  • Candace opened an email from a person she didn't know and clicked on a pop-up in the email that installed a virus on her compute
    8·2 answers
  • Which of the following is NOT contained on the Slide Show toolbar?
    11·2 answers
  • 20 points
    6·2 answers
  • A local bank has an in-house application which handles sensitive financial data in a private subnet. After the data is processed
    15·1 answer
  • Plz help fast! will mark brainliest!<br><br>List three ways that music is used in modern society.
    6·1 answer
  • I need help also this counts as my second giveaway and last for today
    12·2 answers
  • What is HTML? Write some future of HTML.<br>follow for follow ​
    15·2 answers
  • How many 60 KB jpeg files can be stored on a 2 MB folder in your hard drive?​
    7·1 answer
  • What approach do you prefer to take when creating presentations for class projects? Would you rather use software or create pres
    12·2 answers
  • Fictional Corp has a data center that runs multiple internal applications. However, they want to migrate their email to a cloud
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!