Skip to content

Commit

Permalink
Added and removed content for cleaner file
Browse files Browse the repository at this point in the history
  • Loading branch information
Pradetto authored Sep 14, 2022
1 parent dd098dc commit 555df3a
Showing 1 changed file with 21 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
# 1.) Letter Combinations of a Phone Number
# 2.) Generate Parentheses
# 3.) Permutations
# 4.) Permutations II
# 5.) Combinations
# 6.) Subsets
# 7.) Subsets II
# 8.) N-Queens

# https://www.youtube.com/watch?v=1xTBdwghlTo
from collections import deque
print(
'******************************************************************************')
Expand Down Expand Up @@ -477,9 +467,6 @@ def backtrack(i, combo):
'''
Combination Sum I
Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the combinations in any order.
The same number may be chosen from candidates an unlimited number of times. Two combinations are unique if the frequency of at least one of the chosen numbers is different.
Expand Down Expand Up @@ -545,7 +532,6 @@ def helper(i, combo, total):
Combination Sum II
Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to target.
Each number in candidates may only be used once in the combination.
Expand Down Expand Up @@ -583,28 +569,6 @@ def helper(i, combo, total):

class Solution11:
def combinationSum2(self, candidates, target):
# candidates.sort()
# res = []

# def helper(start, combo, target):
# if target == 0:
# res.append(combo.copy())

# if target <= 0:
# return

# prev = -1
# for i in range(start, len(candidates)):
# if candidates[i] == prev:
# continue
# combo.append(candidates[i])
# helper(start + 1, combo, target-candidates[i])
# combo.pop()
# prev = candidates[i]

# helper(0, [], target)
# return res

candidates.sort()

res = []
Expand All @@ -626,7 +590,27 @@ def backtrack(cur, pos, target):

backtrack([], 0, target)
return res
# candidates.sort()
# res = []

# def helper(start, combo, target):
# if target == 0:
# res.append(combo.copy())

# if target <= 0:
# return

# prev = -1
# for i in range(start, len(candidates)):
# if candidates[i] == prev:
# continue
# combo.append(candidates[i])
# helper(start + 1, combo, target-candidates[i])
# combo.pop()
# prev = candidates[i]

# helper(0, [], target)
# return res

s = Solution11()
print('\nSolution 11')
Expand Down Expand Up @@ -786,7 +770,7 @@ def partition(l, r, arr):
Probably wont be asked how to implement a heap from scratch but it is good to know how it works conceptually
'''

# # Python program for implementation of heap Sort
# # Python program for implementation of heap Sort probably not needed but good conceptually

# # To heapify subtree rooted at index i.
# # n is size of heap
Expand Down Expand Up @@ -849,7 +833,6 @@ def partition(l, r, arr):

'''
Inorder Traversal Steps (Recursive and Iterative):
**** NEED TO ADD ITERATIVE CALL *****
1) Visit Left Subtree Recursively
2) Visit Root (or Subtree root)
Expand Down Expand Up @@ -1095,7 +1078,6 @@ def preorder(root):
bst.insert(42)
print(bst.preorderTraversal())


'''
Post-Order Traversal
1) Visit Left Subtree Recursively
Expand All @@ -1113,7 +1095,6 @@ def preorder(root):

print('\nPostOrder Traversal BST')


class Node3:

def __init__(self, data):
Expand Down

0 comments on commit 555df3a

Please sign in to comment.