public int longestMountain(int[] nums) {
        int start = 0;
        int max = 0;
        State state = State.STARTED;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] == nums[i - 1]) {
                start = i;
                state = State.STARTED;
            }
            else if (nums[i] > nums[i - 1]) {
                if (state == State.DECREASING || state == State.STARTED) {
                    start = i - 1;
                    state = State.INCREASING;
                }
            } else {
                if (state == State.INCREASING || state == State.DECREASING) {
                    state = State.DECREASING;
                    max = Math.max(max, i - start + 1);
                } else {
                    start = i;
                }
            }
        }
        return max;
    }
https://leetcode.com/problems/longest-mountain-in-array/description/
src/com/interview/array/LargestMountain.java