1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-12-08 00:45:29 +01:00

refactor: improve Python types for is-valid-array-subsequence/python/function

This commit is contained in:
Divlo 2022-04-24 20:59:53 +02:00
parent b31e144201
commit 45ae2dcf5c
No known key found for this signature in database
GPG Key ID: 8F9478F220CE65E9

View File

@ -1,11 +1,14 @@
from typing import TypeVar
import sys import sys
T = TypeVar('T')
input_values: list[str] = [] input_values: list[str] = []
for value in sys.stdin: for value in sys.stdin:
input_values.append(value.rstrip('\n')) input_values.append(value.rstrip('\n'))
def get_is_valid_subsequence(array: list, sequence: list): def get_is_valid_subsequence(array: list[T], sequence: list[T]) -> bool:
index_to_check = 0 index_to_check = 0
for index in range(len(array)): for index in range(len(array)):
if index_to_check < len(sequence) and array[index] == sequence[index_to_check]: if index_to_check < len(sequence) and array[index] == sequence[index_to_check]: