组合

LeetCode 经典 150 回溯
难度: 中等

题目描述

从 1 到 n 中选出 k 个数的所有组合。

解题思路

使用回溯法,递归选择当前数字或跳过,直到构造出长度为 k 的组合。