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

g1201_1300.s1238_circular_permutation_in_binary_representation.Solution.kt Maven / Gradle / Ivy

There is a newer version: 1.30
Show newest version
package g1201_1300.s1238_circular_permutation_in_binary_representation

// #Medium #Math #Bit_Manipulation #Backtracking
// #2023_06_09_Time_296_ms_(100.00%)_Space_46.6_MB_(100.00%)

class Solution {
    fun circularPermutation(n: Int, start: Int): List {
        val l1: MutableList = ArrayList()
        for (i in 0 until (1 shl n)) {
            l1.add(start xor (i xor (i shr 1)))
        }
        return l1
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy