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
An IT specialist is consulted about setting up a peer-to-peer network. What would the specialist say about security risk in this
ohaa [14]

I just did this, its A

6 0
3 years ago
Read 2 more answers
Please help me on this coding problem :)
Vesnalui [34]

Answer:

a=4 , b=1

Explanation:

I'm not a computer science major at all but I think I can help you with this code.

Our program wants us to add 2 to a get new a value while also subtracting 1 from b value to obtain new b value. We we want to for for as long b is not 0 and a/b is nonnegative.

One round we get:

New a=0+2=2

New b=3-1=2

Let's see if we can go another round:

New a=2+2=4

New b=2-1=1

We can't go another round because b would be negative while a is positive which would make a/b negative. So our loop stops at this 2nd round.

a=4 , b=1

Other notes:

2nd choice makes no sense because a is always going to increase because of the addition on a and b was going to decrease because of the subtraction on it.

Third choice makes no sense because a/b doesn't even exist.

Fourth choice a/b is negative not nonnegative.

4 0
2 years ago
The various online technology tools that enable people to communicate easily via the Internet to share information and resources
seropon [69]

Answer:

Social media is the correct answer for the above question.

Explanation:

  • Social media is the media that is used to communicate with the other person with the help of an internet connection. There is so much software that gives this type of facility. for example whats up and twitter.
  • The above question asked about that technology which is used to connect the people to communicate and the technology is social media which gives the features to connect and communicate all over the world with the help of the internet. Hence "Social media" is the correct answer.
8 0
2 years ago
Explain the difference between using the int type and the double type for numbers.
MaRussiya [10]
They have different semantics, <span>addition to having different semantics from </span>double<span>, </span>int<span> arithmetic is generally faster, and the smaller size (32 bits vs. 64 bits) leads to more efficient use of caches and data transfer bandwidth.....
Did That Help You In Anyway </span>
6 0
3 years ago
Petra has an interview with an IT company. What technique can help prepare her?
SVEN [57.7K]
I would go C because that way it gets her prepared to answer any techie questions they would have for her and would make her a better option.
3 0
2 years ago
Read 2 more answers
Other questions:
  • Encrypt the message ENCRYPTION using a tabular transposition cipher with encryption keyword ONE. If necessary, pad the message w
    7·1 answer
  • What is my credit card billing zip code??
    15·1 answer
  • K. What are the types of page orientation?​
    7·1 answer
  • In a system using the relocatable dynamic partitions scheme, given the following situation (and using decimal form): Job Q is lo
    5·1 answer
  • Is iPhone better than android
    12·2 answers
  • You are going to buy a computer, but first you want to do some research to help you select the best model for your need. Where s
    12·2 answers
  • PLEASE HELP AND FAST!!!!!<br>Which of the following devices uses binary code?
    6·2 answers
  • Taylor and Rory are hosting a party. They sent out invitations, and each one collected responses into dictionaries, with names o
    9·1 answer
  • Which tool allows users to share code and also serves as a social networking
    10·1 answer
  • Prokaryotes are __________________ and include ________________________.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!