21. All Substrings
Required Input:
s = "abc"Expected Output:
['a', 'ab', 'abc', 'b', 'bc', 'c']
Code In Python
def get_all_substrings(s):
# Write your logic here
pass
s = "abc"
print(get_all_substrings(s))
Run Code?
Click Run Button to view compiled output
22. Subsequence Check
Required Input:
s1 = "abc", s2 = "ahbgdc"Expected Output:
True
Code In Python
def is_subsequence(s1, s2):
# Write your logic here
pass
s1 = "abc"
s2 = "ahbgdc"
print(is_subsequence(s1, s2))
Run Code?
Click Run Button to view compiled output
23. Run-Length Encoding
Required Input:
s = "aaabbccccd"Expected Output:
a3b2c4d1
Code In Python
def compress_string(s):
# Write your logic here
pass
s = "aaabbccccd"
print(compress_string(s))
Run Code?
Click Run Button to view compiled output
24. Count Palindromic Substrings
Required Input:
s = "aaa"Expected Output:
6
Code In Python
def count_palindromic_substrings(s):
# Write your logic here
pass
s = "aaa"
print(count_palindromic_substrings(s))
Run Code?
Click Run Button to view compiled output
25. Remove Non-Alphabetic
Required Input:
s = "a1b2c3!@#"Expected Output:
abc
Code In Python
def remove_non_alpha(s):
# Write your logic here
pass
s = "a1b2c3!@#"
print(remove_non_alpha(s))
Run Code?
Click Run Button to view compiled output


