/home/caleb/ASDV-Java/Semester 3/Assignments/Lab_CalebFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/caleb/lab_calebfontenot_maximumorderedstring/FindMaxOrderedSubstring.java |
nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
package edu.slcc.asdv.caleb.lab_calebfontenot_maximumorderedstring;
public class FindMaxOrderedSubstring {
public static String findMaxOrderedSubString(String input) {
String outputString = "";
int j = 0;
for (int i = 0; i < input.length(); ++i) {
if (i == 0) {
outputString += input.charAt(i);
}
if (input.charAt(i) > outputString.charAt(j)) {
++j;
outputString += input.charAt(i);
}
}
return outputString;
}
public static void main(String[] args) {
System.out.println(findMaxOrderedSubString("Welcome!"));
}
}