All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g1201_1300.s1238_circular_permutation_in_binary_representation.Solution Maven / Gradle / Ivy

The newest version!
package g1201_1300.s1238_circular_permutation_in_binary_representation;

// #Medium #Math #Bit_Manipulation #Backtracking
// #2022_03_12_Time_4_ms_(100.00%)_Space_49.9_MB_(90.59%)

import java.util.ArrayList;
import java.util.List;

public class Solution {
    public List circularPermutation(int n, int start) {

        List l1 = new ArrayList<>();
        for (int i = 0; i < (1 << n); i++) {
            l1.add(start ^ (i ^ (i >> 1)));
        }
        return l1;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy