@@ -0,0 +1,1268 @@
+package com.interview.array;%0A%0A/**%0A * https://leetcode.com/problems/longest-mountain-in-array/description/%0A */%0Apublic class LargestMountain %7B%0A%0A    public int longestMountain(int%5B%5D nums) %7B%0A        int start = 0;%0A        int max = 0;%0A        State state = State.STARTED;%0A        for (int i = 1; i %3C nums.length; i++) %7B%0A            if (nums%5Bi%5D == nums%5Bi - 1%5D) %7B%0A                start = i;%0A                state = State.STARTED;%0A            %7D%0A            else if (nums%5Bi%5D %3E nums%5Bi - 1%5D) %7B%0A                if (state == State.DECREASING %7C%7C state == State.STARTED) %7B%0A                    start = i - 1;%0A                    state = State.INCREASING;%0A                %7D%0A            %7D else %7B%0A                if (state == State.INCREASING %7C%7C state == State.DECREASING) %7B%0A                    state = State.DECREASING;%0A                    max = Math.max(max, i - start + 1);%0A                %7D else %7B%0A                    start = i;%0A                %7D%0A            %7D%0A        %7D%0A        return max;%0A    %7D%0A%0A    enum State %7B%0A        STARTED,%0A        INCREASING,%0A        DECREASING;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        LargestMountain lm = new LargestMountain();%0A        int%5B%5D nums = %7B2, 1, 4, 7, 3, 2, 5%7D;%0A        System.out.println(lm.longestMountain(nums));%0A    %7D%0A%7D%0A

Find largest mountain in the array