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
Write a program that displays in the title of the window the position of the mouse as the user moves the mouse around the window
12345 [234]
The java program displays these 
4 0
3 years ago
Difference between volatile and non volatile memory
slega [8]
<span>Volatile memory requires electricity or some kind of current to store information, and nonvolatile memory does not.</span>
6 0
3 years ago
Read 2 more answers
Hardware refers to programs and protocols used on a computer system.<br><br> True<br> False
lapo4ka [179]

Answer:

False

Explanation:

7 0
2 years ago
Read 2 more answers
If a firm is set to use open-source software with which no one in the IT department is familiar, what should it do? fire the IT
Aleonysh [2.5K]
The most efficient thing to do would be to provide training as firing or doing nothing halts productivity indefinitely while training eventually will finish
7 0
2 years ago
Read 2 more answers
Your company deals with highly confidential information, some of which is transmitted via email among employees. Some documents
S_A_V [24]

Answer: AD RMS(Active Directory Rights Management Services)

Explanation: Active Directory Rights Management Services (AD RMS) is the tool for security that provides the protection of data .The security of data is maintained by the policies and regulation of data accessing that are implemented on data .

The working of the AD RMS is based on the RMS applications which encrypts the document and generates the regulation and stamp to collect them in an individual files.This helps in protecting the information that being created and consumed.

7 0
3 years ago
Other questions:
  • Suppose a computer can execute 1 billion instructions/sec and that a system call takes 1000 instructions, including the trap and
    10·1 answer
  • Enhancing and optimizing customer retention and loyalty is a major business strategy.
    15·1 answer
  • What are 2 ways that technology can negatively impact the environment.
    8·2 answers
  • How can I make a website login system with only using php?​
    6·1 answer
  • A<br> is an list of steps to complete a task. *
    9·1 answer
  • Kylee needs to ensure that if a particular client sends her an email while she is on vacation, the email is forwarded to a
    5·1 answer
  • In order to enhance the training experience and emphasize the core security goals and mission, it is recommended that the execut
    5·1 answer
  • Simple interest will always pay more interest than compound interest.
    14·1 answer
  • If your cell phone rings while you are driving and you do not have a hands-free device you should
    9·1 answer
  • I have the requirements for Ace rank on Brainly but hasn't given me it yet. Does it just take longer than normal ranks or someth
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!