2019-05-09 19:32:54 +08:00
|
|
|
package Others;
|
2017-09-29 06:49:28 +08:00
|
|
|
|
2019-05-09 19:32:54 +08:00
|
|
|
/**
|
|
|
|
* An Abecadrian is a word where each letter is in alphabetical order
|
|
|
|
*
|
|
|
|
* @author Oskar Enmalm
|
|
|
|
*/
|
|
|
|
class Abecedarian {
|
|
|
|
|
|
|
|
public static boolean isAbecedarian(String s) {
|
2017-09-29 06:49:28 +08:00
|
|
|
int index = s.length() - 1;
|
|
|
|
|
2019-05-09 19:32:54 +08:00
|
|
|
for (int i = 0; i < index; i++) {
|
2017-09-29 06:49:28 +08:00
|
|
|
|
2019-05-09 19:32:54 +08:00
|
|
|
if (s.charAt(i) <= s.charAt(i + 1)) {
|
|
|
|
} //Need to check if each letter for the whole word is less than the one before it
|
2017-09-29 06:49:28 +08:00
|
|
|
|
2019-05-09 19:32:54 +08:00
|
|
|
else {
|
|
|
|
return false;
|
2017-09-29 06:49:28 +08:00
|
|
|
}
|
2017-10-27 07:56:18 +08:00
|
|
|
}
|
2019-05-09 19:32:54 +08:00
|
|
|
return true;
|
|
|
|
}
|
2017-09-29 07:04:24 +08:00
|
|
|
}
|