@@ -0,0 +1,1432 @@
+class Solution %7B%0A    public int nextGreaterElement(int n) %7B%0A        char%5B%5D str = (n+%22%22).toCharArray();%0A%0A        int deflectionPoint = str.length-1;%0A%0A        while(deflectionPoint%3E0)%7B%0A            if(str%5BdeflectionPoint%5D %3E str%5BdeflectionPoint-1%5D) %7B%0A                break;%0A            %7D%0A            deflectionPoint--;%0A        %7D%0A        if(deflectionPoint == 0)%7B%0A            return -1;%0A        %7D%0A%0A        int firstSwappingIndex = deflectionPoint -1;%0A%0A        int secondSwappingIndex = str.length -1;%0A        while(secondSwappingIndex%3E=firstSwappingIndex)%7B%0A            if(str%5BfirstSwappingIndex%5D %3C str%5BsecondSwappingIndex%5D) %7B%0A                break;%0A            %7D%0A            secondSwappingIndex--;%0A        %7D%0A%0A        // swap%0A%0A        char temp = str%5BfirstSwappingIndex%5D;%0A        str%5BfirstSwappingIndex%5D = str%5BsecondSwappingIndex%5D;%0A        str%5BsecondSwappingIndex%5D = temp;%0A%0A        // swapping at the point of deflection%0A%0A        reverseChar(str, deflectionPoint);%0A        String s=new String(str);%0A        try%7B%0A        int res=Integer.parseInt(s);%0A        return res;%0A        %7D%0A        catch(Exception e)%7B%0A            return -1;%0A        %7D%0A    %7D%0A%0A    private void reverseChar(char%5B%5D str, int i)%7B%0A        int start = i;%0A        int end =str.length-1;%0A        while(end%3E=start)%7B%0A            char temp = str%5Bstart%5D;%0A            str%5Bstart%5D = str%5Bend%5D;%0A            str%5Bend%5D = temp;%0A            end--;%0A            start++;%0A%0A        %7D%0A    %7D%0A%0A%0A%7D%0A

Create NextGreaterElement.java