I have to find all the combinations in an array a[] with indices i,j,k such that i<j<k and have to perform one operation for every combination
for example in an array
int a[] = {12,1,34,32}
the combination are
{12,1,34},{12,1,32},{12,34,32}.{1,34,32}

I have tried recursive way and storing all the combinations in a set so that if I visit the same combination again I will return from there only by checking it from the set

my code is this but i am getting TLE for large cases
can anyone please provide me the most efficient way for this

```
 static Set<String> set = new HashSet<>();
 static int sum = 0;

    static void solve(int i,int j,int k,int[] a){
        if(i>=j || j>=k ||k>=a.length){
            return;
        }

        //combination
        String pre = String.valueOf(i)+String.valueOf(j)+String.valueOf(k);
        if(set.contains(pre)){
            return;
        }

        //operation to perform for every combination
        int v = (a[i] | a[j] | a[k]) ^ (a[i] ^ a[j] ^ a[k]);
        sum = sum+v;

        solve(i,j,k+1,a);
        solve(i,j+1,k,a);
        solve(i+1,j,k,a);
    }

```