#3470
Permutations IV
hard · 34% accepted · 28 likes · top 11%
array · math · combinatorics · enumeration
Description
Given two integers, n and k, an alternating permutation is a permutation of the first n positive integers such that no two adjacent elements are both odd or both even.
Return the k-th alternating permutation sorted in lexicographical order. If there are fewer than k valid alternating permutations, return an empty list.
Solution