Skip to content

Commit

Permalink
Merge pull request #989 from sujijava/main
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Jul 29, 2024
2 parents 4883afc + 96a8cee commit a90ab00
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Empty file.
12 changes: 12 additions & 0 deletions sujioh/2024-07-26-permutations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution:
def permute(self, num):
res = [[]]
for n in num:
size = len(res)
for _ in range(size):
r = res.pop(0)
for i in range(len(r) + 1):
t = r[:]
t.insert(i, n)
res.append(t)
return res
19 changes: 19 additions & 0 deletions sujioh/2024-07-27-subsets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from typing import List


class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
res = []
subset = []

def dfs(i):
if i == len(nums):
res.append(subset.copy())
return
subset.append(nums[i])
dfs(i+1)
subset.pop()
dfs(i+1)

dfs(0)
return res

0 comments on commit a90ab00

Please sign in to comment.