Program to Print all subarrays of a array in efficient way
void Subarray(int arr[],int n){
for(long long i=0;i<(1<<n);i++){ for(long long j=0;j<n;j++){ if((i & 1<<j)>0) { cout<<arr[j]; } } cout<<endl; } }
void Subarray(int arr[],int n){
for(long long i=0;i<(1<<n);i++){ for(long long j=0;j<n;j++){ if((i & 1<<j)>0) { cout<<arr[j]; } } cout<<endl; } }
Comments
Post a Comment