1.- if you use bitmask can be easy solved
2.- second aproach is create un recursion
string func(int idx, int cnt){
if(cnt==r)return "";;
string ans = func(idx+1, cnt);
if(cnt<r) ans = ans+"\n" + func(idx+1, cnt+1) + a[idx];
return ans;
}
On Sunday, May 19, 2013 10:08:10 AM UTC-5, rahul sharma wrote:
>
> Generate all possible combinations (of r elements) inside an array of
> size N
> E.g. arr [] = {2,8,14} All possible combinations of r=2 will be {2,8},
> {8,14}, {14,2}
>
> Asked in adobe
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].