mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 09:21:13 +08:00
Pyupgrade to Python 3.9 (#4718)
* Pyupgrade to Python 3.9 * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@ -5,15 +5,17 @@ of the given sequence. We use backtracking to solve this problem.
|
||||
Time complexity: O(2^n),
|
||||
where n denotes the length of the given sequence.
|
||||
"""
|
||||
from typing import Any, List
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
|
||||
def generate_all_subsequences(sequence: List[Any]) -> None:
|
||||
def generate_all_subsequences(sequence: list[Any]) -> None:
|
||||
create_state_space_tree(sequence, [], 0)
|
||||
|
||||
|
||||
def create_state_space_tree(
|
||||
sequence: List[Any], current_subsequence: List[Any], index: int
|
||||
sequence: list[Any], current_subsequence: list[Any], index: int
|
||||
) -> None:
|
||||
"""
|
||||
Creates a state space tree to iterate through each branch using DFS.
|
||||
@ -32,7 +34,7 @@ def create_state_space_tree(
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
seq: List[Any] = [3, 1, 2, 4]
|
||||
seq: list[Any] = [3, 1, 2, 4]
|
||||
generate_all_subsequences(seq)
|
||||
|
||||
seq.clear()
|
||||
|
Reference in New Issue
Block a user