Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4084292
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:25:16+00:00 2026-05-20T18:25:16+00:00

I wanted to print an array with repetitive numbers inside parenteses, any idea of

  • 0

I wanted to print an array with repetitive numbers inside parenteses, any idea of how?

array:

{2,4,5,5,5,7,1,1,4}

I need to print it as:

24(555)7(11)4

Here’s my pseudocode:

boolean inRun = false;
 for loop;
 if (inRun); 
if values[i] != the preceding value, print ")"; 
inRun = false; 
if(!inRun) 
if values[i] = the following value, print "("
 inRun = true; 
System.out.print([i]) 
if inRun, print ")" 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:25:17+00:00Added an answer on May 20, 2026 at 6:25 pm
    import java.util.Arrays;
    
    public class Test{
        public static void main(String[] args){
    
    
            int arr[] = new int[5];
            arr[0] = 5;
            arr[1] = 3;
            arr[2] = 2;
    
            arr[3] = 2;
    
            arr[4] = 3;
    
    
            Arrays.sort(arr);
            System.out.print("(" + arr[0]);
            for (int i=1; i<arr.length;i++) {
                if(arr[i] == arr[i-1]) {
                    System.out.print(arr[i]);
                }
                else {
                    System.out.print(")(" + arr[i]);
                }
            }
    
            System.out.print(")");
        }
    }
    

    output : (22)(33)(5)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a associative array and i wanted to print out all the column
In the example below, if client code using GetPeople wanted to print the name
I just learnt XSLT today when I wanted to pretty print the playlist export
I wanted to wrap a small C++ code allocating an array with ctypes and
i have an array with some double value inside: private double speed[] = {50,
i did this code : from scitools.std import * npoints=10 vectorpoint=array(random.uniform(-1,1,[1,2])) experiment=array(random.uniform(-1,1,[npoints,2])) print(vectorpoint=,vectorpoint) print(experiment=,experiment)
This question is actually inspired from another one here on SO and I wanted
I wanted to convert string into array of bytes . How can i do
I am learning shell(ksh) scripting. I wanted to know what does ${array[three]} mean in
I've got the following 2D array, stored inside the array variable $my_array Array (

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.