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.
`Hey,
Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries
import java.util.*;
public class TEST {
public static void main(String[] args) {
// Create a Scanner
Scanner input = new
Scanner(System.in);
LinkedList<Character> max =
new LinkedList<>();
LinkedList<Character> list =
new LinkedList<>();
// Prompt the user to enter
a string
System.out.print("Enter a string:
");
String string =
input.nextLine();
// Find the maximum
consecutive increasingly ordered substring
for (int i = 0; i <
string.length(); i++) { // single
loop
if (list.size()
> 1 && string.charAt(i) <= list.getLast()
&&
list.contains(string.charAt(i))) {
list.clear(); // Simple statement
}
list.add(string.charAt(i)); // Simple statement
if
(list.size() > max.size()) { // Simple statement
max.clear();
max.addAll(list);
}
}
// Display the maximum
consecutive
// increasingly ordered
substring
for (Character ch: max) { // single
loop
System.out.print(ch); // Simple statement
}
System.out.println();
}
}
Time complexity is O(n) since it is traversing whole string constant times.
Kindly revert for any queries
Thanks.
IN JAVA (Maximum consecutive increasingly ordered sub-string) Write a program that prompts the user to enter...
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.
write a java program that displays the following: Write a Java program that prompts the user to enter an integer and determines whether 1. it is divisible by 5 and 6, whether on 2. it is divisible by 5 or 6, 3. it is divisible by 5 or 6, but not both. Here is a sample run of this program: Sample run: Enter an integer: 10 Is 10 divisible by 5 and 6? false Is 10 divisible by 5 or...
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...
Problem 1.Write a program that prompts the user to enter the number of milliseconds and converts the milliseconds to a string hours:minutes:seconds. The program should use the convertMillismethod with the following header:public static String convertMillis(long millis)For example, convertMillis(5500) returns the string 0:0:5, convertMillis(100000) returns the string 0:1:40, andconvertMillis(555550000) returns the string154:19:10.Problem 2. (Count occurrence of numbers)Write a program that reads integers between 1 and 100 and counts the occurrence of each (you should store the numbers in an array). Output...
Write a program that prompts the user to enter a question (string) and display whether the question is correct. It is correct if it ends with the question mark (?) ----vyrovusmyzustning%20Class.pdf Programs with String Class Write a program that prompts the user to enter a question (string) and display whether the question is correct. It is correct if it ends with the question mark (?) Ask a question? Ask a question? How old are you What is your name? That's...
In Java - Write a program that prompts the user to enter two integers and displays their sum. If the input is incorrect, prompt the user again. This means that you will have a try-catch inside a loop.
java programe Write a program that prompts the user to enter in an integer number representing the number of elements in an integer array. Create the array and prompt the user to enter in values for each element using a for loop. When the array is full, display the following: The values in the array on a single line. The array with all of the elements reversed. The values from the array that have even numbered values. The values from...
(Process a string) Write a program that prompts the user to enter a string and displays its length and its first character. java StringLength Enter a string:Does quantum determinacy have anything to with whether human cognition is deterministic? The string is of length 88 and the first character is D import java.util.Scanner; class StringLength{ public static void main (String args[]){ Scanner input = new Scanner(System.in); System.out.println("Enter a string:"); String ans = input.nextLine(); System.out.println("The string...
Write a program that prompts the user for a string and stores the user's string into a variable using getline(). After receiving the string, the program counts and displays the number of vowels in the string. Then, the program should prompt the user if they would like to enter another string.
Design a program that prompts the user to enter a string, and displays the character that appears most frequently in the string. (Please read the problem above carefully. I'm asking this question for the second time because the last answer I received wasn't even paying attention to what the question asked for.) Answer MUST be using Flowgorithm with screenshots. Please attach a screenshot of the program successfully running in flowgorithm as well to confirm proper output. Thanks for understanding!