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]
4 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]4 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
PLEASE HELP!!! THIS IS DUE TODAY!! WIL MARK BRAINLIEST!!<br> What value does Netflix bring to people
ki77a [65]

Answer:

it allows people to distract themselves from the things going on, it also entertains people

Explanation:

hope this helps

7 0
3 years ago
Read 2 more answers
What is the name of database of viruses that an antivirus software scan for?
Andrew [12]

Answer:

Anti virus scanner. i hope :)

Explanation:

7 0
3 years ago
Write the function "zipper". the function will take two array/list/table parameters and return a new array/list/table which will
MakcuM [25]
What is the problem what am I supposed to do?
4 0
4 years ago
2. How can recovery handle transaction operations that do not affect the database, such as the printing of reports by a transact
Reil [10]

Answer:

Explanation:

great question but dont know

7 0
3 years ago
Kevin is working on a memory chip that can be written on and erased electronically. What type of chip is
kherson [118]

Answer:

EEPROM (Electrically Erasable programmable ROM)

Explanation:

ROM is the memory chip that is used to store the data permanently. To store and erase data on the ROM multiple time with the help of electronically is called EEPROM. In this ROM we can write and erase data multiple times.

The most common example of this type of memory is Flash Memory. It is non volatile memory. If we need to write or erase data on this chip, we just plug into USB port of computer. Then delete the data that is needed no more.

5 0
3 years ago
Other questions:
  • What is the purpose of a budget
    7·1 answer
  • Regularly Tuning up a computer can assist keeping it running at Peak speed. True or False?
    12·1 answer
  • You're familiar with the story of Hansel and Gretel, so when you decide to go exploring you always make sure to keep track of wh
    14·1 answer
  • Which of the following is true about images that are arranged in a collumn
    9·1 answer
  • Select the correct answer from each drop-down menu. What skills should Tara hone to get a job in testing? Tara is a recent compu
    12·1 answer
  • A user complains that Skype drops her videoconference calls and she must reconnect. At which layer of the OSI model should you b
    9·1 answer
  • A relational database is different from a simple database because it has more than one _____.
    13·1 answer
  • (1)similarities between backspace key and delete key. (2) different between backspace key and delete key. (3) explain the term e
    10·1 answer
  • Yo need help can someone plz help
    7·1 answer
  • Which structural semantic will this HTML code snippet form?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!