Last active
April 25, 2025 08:39
-
-
Save vivek-vijayan/e4693c8254d1ccb77cb21753c1e01d21 to your computer and use it in GitHub Desktop.
Quicker way of finding the Sub sequence values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = "abcdefg" | |
l = ["a", "acef", "defg", "gg"] | |
word_count = 0 | |
for word in l: | |
i = 0 # pointer in main string | |
for ch in word: | |
i = a.find(ch, i) | |
if i == -1: | |
break | |
i += 1 | |
else: | |
word_count += 1 | |
print(word_count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment