Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6420 |

@blackshadows | 6380 |

@mb1973 | 5646 |

@Quandray | 5233 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4716 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3413 |

Complete Leaderboard | |

Handle | Score |

@skj7 | 671 |

@gurshehzadsingh | 418 |

@swastik8750 | 411 |

@nishunishuraj18 | 405 |

@vedantvalsangkar | 390 |

@deepakchowdary | 380 |

@akashverma4 | 369 |

@satyamannsm | 353 |

@2018uec1603 | 341 |

@rkrupeshkumar345 | 335 |

@surajmamgai | 330 |

Complete Leaderboard |

Given an array arr of N integers and an integer K, find the number of subsets of arr having XOR of elements as K.

**Example 1:**

Input:N = 4 k = 6 arr: 6 9 4 2Output:2Explanation:The subsets are {4,2} and {6}

**Example 2:**

Input:N = 5 K = 4 arr: 1 2 3 4 5Output:4Explanation:The subsets are {1, 5}, {4}, {1, 2, 3, 4}, and {2, 3, 5}

**Your Task:**

You don't need to read input or print anything. Your task is to complete the function **subsetXORâ€‹()** which takes the array arr[], its size N and an integer K as input parameters and returns the number of subsets having xor as K

**Expected Time Complexity: **O(N*M)

**Expected Space Complexity: **O(N*M)

Note: M = maximum value any XOR subset will acquire

**Constraints:**

1<=N<=20

1<=K<=100

0<=arr[i]<=100

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Subsets with XOR value

...