#Java 7, <s>157</s> <s>153</s> <s>150</s> <s>125</s> 117 bytes int c(char[]z){for(int i=2,a,b,c;i<z.length;i++)if(((a=z[i-1])<(c=z[i])&(b=z[i-2])<a)|(a>=c&b>=a))return 0;return 1;} **Ungolfed & test cases:** [Try it here.](https://ideone.com/xyVeXO) class M{ static int c(char[] z){ for(int i = 2, a, b, c; i < z.length; i++){ if(((a = z[i-1]) < (c = z[i]) & (b = z[i-2]) < a) | (a >= c & b >= a)){ return 0; //false } } return 1; //true } public static void main(String[] a){ System.out.print(c("ABA".toCharArray()) + ", "); System.out.print(c("ABB".toCharArray()) + ", "); System.out.print(c("BAB".toCharArray()) + ", "); System.out.print(c("BUMP".toCharArray()) + ", "); System.out.print(c("BALD".toCharArray()) + ", "); System.out.print(c("BALDY".toCharArray()) + ", "); System.out.print(c("UPWARD".toCharArray()) + ", "); System.out.print(c("EXAMINATION".toCharArray()) + ", "); System.out.print(c("AZBYCXDWEVFUGTHSIRJQKPLOMN".toCharArray()) + ", "); System.out.print(c("AAA".toCharArray()) + ", "); System.out.print(c("ACE".toCharArray()) + ", "); System.out.print(c("THE".toCharArray()) + ", "); System.out.print(c("BUMPY".toCharArray()) + ", "); System.out.print(c("BALDING".toCharArray()) + ", "); System.out.print(c("ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray()) + ", "); } } **Output:** 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0