This repository contains a JavaScript function called getUniqueSubsets
that generates all unique subsets of a set of integer numbers, as specified in the problem.
The getUniqueSubsets
function is responsible for generating unique subsets of a set of integer numbers. It uses bitwise manipulation to optimize the subset generation process. The function takes an array of integer numbers as input and returns an array of arrays containing all the unique subsets.
const getUniqueSubsets = require("./src/getUniqueSubsets");
const nums = [1, 2, 3];
const subsets = getUniqueSubsets(nums);
console.log(subsets);
This repository includes tests written using the Jest test library. The tests cover different scenarios to ensure that the getUniqueSubsets
function works correctly.
Make sure you have Node.js and installed the dependencies.
-
Clone this repository to your local environment.
-
Navigate to the repository folder:
cd path-to-repository
- Run the tests:
npm test
This will execute the tests defined in the test file and display the results in the terminal.
The tests include the following scenarios:
- An empty set results in only one subset (an empty set).
- Generating subsets for a small set where order does not matter.
- Equal sets should be considered in a subset.
- Efficient handling of a large set.
- Inclusion of an empty set for a non-empty set and an empty set.
- Two empty sets result in only one subset (an empty set).
Make sure the tests pass correctly after execution.