Class Solution

java.lang.Object
g0001_0100.s0077_combinations.Solution

public class Solution extends Object
77 - Combinations.<p>Medium</p> <p>Given two integers <code>n</code> and <code>k</code>, return <em>all possible combinations of</em> <code>k</code> <em>numbers out of the range</em> <code>[1, n]</code>.</p> <p>You may return the answer in <strong>any order</strong>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> n = 4, k = 2</p> <p><strong>Output:</strong> [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ]</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> n = 1, k = 1</p> <p><strong>Output:</strong> <a href="1">1</a></p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= n <= 20</code></li> <li><code>1 <= k <= n</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details