Please answer in Python 3! 16.2** (Maximum increasingly ordered subsequence) Write a program that prompts the user to enter a string and displays the maximum increasingly ordered subsequence of characters. Analyze the time complexity of your program. Here is a sample run: Enter a string: Welcome Maximum consecutive substring is ['W', 'e', 'l', 'o']
If You Have Any Doubt Please Comment Below
Code:-
def Maximumconsecutivesubstring(str):
l = len(str)
count = 0
# Find the maximum repeating
# character starting from str[i]
res = str[0]
for i in range(l):
cur_count = 1
for j in range(i + 1, l):
if (str[i] != str[j]):
break
cur_count += 1
# Update result if required
if cur_count > count :
count = cur_count
res = str[i]
return res
# Driver code
if __name__ == "__main__":
str = "Hi this is HomeworkLib qqquestiom"
print("Maximum consecutive substring is ")
print(Maximumconsecutivesubstring(str))
Output:-
Please answer in Python 3! 16.2** (Maximum increasingly ordered subsequence) Write a program that prompts the...
IN JAVA (Maximum consecutive increasingly ordered sub-string) Write a program that prompts the user to enter a string and displays the maximum consecutive increasingly ordered sub-string. Analyze the time complexity of your program and explain. Here is a sample run: Enter a string: abcabcdgabxy output abcdg Time complexity is O( ). -n must be display between the parenthesis.
Need answer in Python 3.8, with indentation and comments shown, please. 16.4* (Pattern matching) Write a program that prompts the user to enter two strings and tests whether the second string is a substring in the first string. (Don't use the find method in the str class.) Analyze the time complexity of your algorithm. Here is a sample run of the program <output> Enter a string s1: Mississippi Enter a string s2: sip matched at index 6 <End Output>
(Same-number subsequence) Write an O(n) program in python that prompts the user to enter a sequence of integers and finds longest subsequence with the same number. Here is a sample run of the program: <Output> Enter a series of numbers ending with 0: 2 4 4 8 8 8 8 2 4 4 0 The longest same number sequence starts at index 3 with 4 values of 8 <End Output>
(Same-number subsequence) Write an O(n) program that prompts the user to enter a sequence of integers in one line and finds longest subsequence with the same number. Sample Run Enter a series of numbers: 2 4 4 8 8 8 8 2 4 4 0 The longest same number sequence starts at index 3 with 4 values of 8. In Python.
Program must be in Python 3. Write a program that prompts the user to enter two strings and then displays a message indicating whether or not the first string starts with the second string. Your program must satisfy the following requirements. 1. Your program must include a function called myStartsWith that takes two string parameters. This function returns True if the rst string starts with the second string and returns False otherwise. 2. Your program must include a main function...
Write a program that prompts the user to enter a binary string and displays the corresponding decimal integer value. For example, binary string ‘10001’ is 17 (1*24 +0*23 +0*22 +0*2 + 1 = 17) A sample run : Enter a binary: 10001 17 Enter second integer: 110 6 Use python.
Python 3 **11.40 (Guess the capitals) Write a program that repeatedly prompts the user to enter a capital for a state. Upon receiving the user input, the program reports whether the answer is correct. Assume that 50 states and their capitals are stored in a two- dimensional list, as shown in Figure 11.13. The program prompts the user to answer all the states’ capitals and displays the total correct count. The user’s answer is not case sensitive. Implement the program...
Write a Python program that prompts the user to enter their three favorite bands separate by commas, and prints their selections on three separate bands. Hint: You will need to use the string function, split. A sample run appears below (user input shown in bold): Enter your favorite bands separated by commas: The Beatles,Queen,Bruce Springsteen My favorite bands are: The Beatles Queen Bruce Springsteen
Please write code in C++ and include all headers not bits/stdc: 17.10 (Occurrences of a specified character in a string) Write a recursive function that finds the number of occurrences of a specified letter in a string using the following function header. int count(const string& s, char a) For example, count("Welcome", 'e') returns 2. Write a test program that prompts the user to enter a string and a character, and displays the number of occurrences for the character in the...
USE PYTHON 3Write a program that prompts the user to enter the number of students and each student's score, and displays the highest and second- highest scores.