g1201_1300.s1238_circular_permutation_in_binary_representation.Solution Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-java Show documentation
Show all versions of leetcode-in-java Show documentation
Java-based LeetCode algorithm problem solutions, regularly updated
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