Added all sub sequence type hints [Hacktober Fest] (#3123)

* updating DIRECTORY.md

* chore(all-subsequence): added type hints [HACKTOBER-FEST]

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
Tapajyoti Bose
2020-10-10 11:49:36 +05:30
committed by GitHub
parent 927e14e7f2
commit 8bd4ca67be
2 changed files with 12 additions and 5 deletions

View File

@@ -1,3 +1,5 @@
from typing import Any, List
"""
In this problem, we want to determine all possible subsequences
of the given sequence. We use backtracking to solve this problem.
@@ -7,11 +9,13 @@
"""
def generate_all_subsequences(sequence):
def generate_all_subsequences(sequence: List[Any]) -> None:
create_state_space_tree(sequence, [], 0)
def create_state_space_tree(sequence, current_subsequence, index):
def create_state_space_tree(
sequence: List[Any], current_subsequence: List[Any], index: int
) -> None:
"""
Creates a state space tree to iterate through each branch using DFS.
We know that each state has exactly two children.