Jeez !!

Ppl take immediate offense to a puzzle ..

Some clarifications:

Its not part of my homework. I was just browsing through some

Microsoft interview Qs and got stumped over this one. Agreed I might

be low on the IQ front but just to prove my homework

I had figured out a soln already. But it was O(N^2).

Understanding the problem -

To figure out the sum of the elements of those ordered sub-sets of the

set {X1,..,Xn} such that:

for any sub-set {Xi,..,Xj}, (i < j) && ((j - i) = Cardinality of

{Xi,..,Xj}).

Soln to the problem -

This boils down to running two nested for loops as we do in case of

bubble sort.

But I am still looking for the O(N) algo.

~RG

ps -> Spare me for the mistakes in the formal notations. I am not good

at them.