If the indices are "normal", you can adapt the code from http://www.jsoftware.com/pipermail/general/2008-July/032128.html
If the indices are theoretical, e.g. containing numbers like 2e9 and impractical to be expanded into a vector of that length, then something else needs to be done. ----- Original Message ----- From: Raul Miller <[email protected]> Date: Thursday, March 25, 2010 11:40 Subject: [Jprogramming] parenthesis balancing To: Programming forum <[email protected]> > Does anyone remember how to efficiently solve problems like this: > > (I think we have solved similar issues in the past, but I am not > finding the relevant messages.) > > Given a list of positions for left and right parenthesis, arranged > in ascending order: > > 12 34 36 47 70 > 30 44 54 59 82 > > Return the positions for the right parenthesis arranged to correspond > with their matching left parenthesis. > > 30 59 44 54 82 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
