Back to problems

Choose k numbers from 1..n without repetition (combinations / permutations)

Algorithm · ByteDance · Medium

For integers n and k, with 1 <= k <= n, select k different values from {1, 2, ..., n}. Produce output for either of these modes, or for both when requested: Combination (C): select k values without considering their arrangement. List every combination. Permutation of length k (P): select k values while treating different arrangements as different results. List every permutation containing k values. Input The input consists of one line containing three fields: mode: either…

Checking your access…