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 ")"
output : (22)(33)(5)