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
IT professionals recognize that successful systems must be user-oriented, and users need to be involved, formally or informally,
elixir [45]

Answer: True

Explanation:

System development is the process in which a system is developed,planned, designed,tested, modified etc. Analysis of design,internal structure and external factors is done for implementation to creation of system.

  • An IT professional is responsible for performing various tasks in system development.He/she has to analyze and detect that the developed system is convenient for user.
  • Involvement of user also plays an important part in system development through various ways such as improvement in system, smooth implementation,innovation,enhancing quality etc.
  • So, user can be involved in official or unofficial manner for betterment of system development.
  • Thus, the given statement is true.
3 0
3 years ago
You would like to create a graph that shows how much of your total investments are in stocks, savings, and mutual funds. You sho
sdas [7]
The answer is D. line graph
4 0
3 years ago
Read 2 more answers
graphic designers can compress files in different formats . One of the formats ensures that the quality and details of the image
musickatia [10]

Answer:

The format that is used is: PNG

Explanation:

7 0
3 years ago
Advancements in nuclear science have led to technological advances which are both harmful and beneficial. Which would be conside
ExtremeBDS [4]
<span>C) magnetic resonance imaging (MRI) 

hope it helped

</span>
5 0
3 years ago
Write a SELECT statement that joins the Categories table to the Products table and returns these columns: category_name, product
Sphinxa [80]

Answer & Explanation:

1) Query:

SELECT Product_Name, Category_Name, List_Price

FROM Products AS P JOIN Categories AS C

ON C.Category_ID = P.Category_ID

ORDER BY Category_Name, Product_Name ASC;

2) Query:

SELECT C.Last_Name, C.First_Name, Order_Date, P.Product_Name, Item_Price, Discount_Amount, Quantity

FROM Customers AS C JOIN Orders AS O

ON C.Customer_ID = O.Customer_ID

JOIN Order_Items AS OI

ON O.Order_ID = OI.Order_ID

JOIN Products AS P

ON OI.Product_ID = P.Product_ID

ORDER BY Last_Name, Order_Date, Product_Name;

3) Query:

SELECT Category_Name, Product_ID

FROM Categories LEFT JOIN Products

ON Categories.Category_ID = Products.Category_ID

WHERE Product_ID IS NULL;

4) Query:

SELECT 'SHIPPED' AS Ship_Status, Order_Id, Order_Date

FROM Orders

WHERE Ship_Date IS NOT NULL

UNION

SELECT 'NOT SHIPPED' AS Ship_Status, Order_ID, Order_Date

FROM Orders

WHERE Ship_Date IS NULL

ORDER BY Order_Date;

3 0
3 years ago
Other questions:
  • An administrator working on a Windows Server 2016 Server Core installation needs to disable DHCP on all interfaces on the server
    12·1 answer
  • 5. How should you use LinkedIn Answers as a professional?
    8·1 answer
  • You have answered 4 of 18 questions.
    12·2 answers
  • What to do when you strip a screw
    10·2 answers
  • Community gardens are public gardens where local residents can grow plants in a plot. They are very popular, so there are often
    7·1 answer
  • How do u type faster
    5·1 answer
  • Cual es la fiabilidad de la innovacion tecnologica
    15·1 answer
  • Who Likes K-pop? Which group or groups do you like
    12·2 answers
  • What term is used to describe our connection with eachother through technology
    6·1 answer
  • क) मानौं तिमी बसेको समाजमा मान्छेहरूले सधै फोहर फाल्ने गर्नाले वातावरण प्रदूषित
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!