2022-05-25
Description
Given two integers n and k, return all possible combinations of k numbers out of the range [1, n].
You may return the answer in any order.
Example 1:
Input: n = 4, k = 2
Output:
[
[2,4],
[3,4],
[2,3],
[1,2],
[1,3],
[1,4],
]Example 2:
Input: n = 1, k = 1
Output: [[1]]Constraints:
1 <= n <= 201 <= k <= n
Solution
Approach #0: DFS
Approach #1: Alphabetical Order
Description
Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= nums.length <= 6-10 <= nums[i] <= 10All the integers of
numsare unique.
Solution
Approach #0
Approach #1
Description
Given a string s, you can transform every letter individually to be lowercase or uppercase to create another string.
Return a list of all possible strings we could create. Return the output in any order.
Example 1:
Example 2:
Constraints:
1 <= s.length <= 12sconsists of lowercase English letters, uppercase English letters, and digits.
Solution
Approach #0: Too Slow
Approach #1: Much Better
Last updated