Best algorithm to group and add in a list of following pattern

Let us consider we have objects in a list as

listOfObjects = [a,b,ob,ob,c,ob,c,ob,c,ob,ob,c,ob]

we have to group them as

[ob,ob,c,ob,c,ob] from index 2 to 7

[ob,ob,c,ob] from index 9 to 12

i.e the group starts if we have two ob's together and ends before the 'c' having two ob's following or if the list ends.

So what will be the best algorithm to get the above(in java)?...

Read More »

By: StackOverFlow - 6 days ago

Related Posts