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

feat(solutions): add is-valid-array-subsequence/python/function

This commit is contained in:
Divlo 2022-04-23 21:48:12 +02:00
parent c4b0e9e757
commit 64c5d41358
No known key found for this signature in database
GPG Key ID: 8F9478F220CE65E9
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,3 @@
# is-valid-array-subsequence/python/function
Created by [@Divlo](https://github.com/Divlo) on 23 April 2022.

View File

@ -0,0 +1,19 @@
from typing import List
import sys
input_values: List[str] = []
for value in sys.stdin:
input_values.append(value.rstrip('\n'))
def get_is_valid_subsequence(array: List, sequence: List):
index_to_check = 0
for index in range(len(array)):
if index_to_check < len(sequence) and array[index] == sequence[index_to_check]:
index_to_check += 1
return index_to_check == len(sequence)
is_valid_subsequence = get_is_valid_subsequence(
input_values[0].split(' '), input_values[1].split(' '))
print('true' if is_valid_subsequence else 'false')