Didn't see any Java solution here, because nobody knows how to mod?
Sadly me neither\n```\nclass Solution {\n    long mod = (int) 1e9 + 7;\n    public int numOfWays(int[] nums) {\n        List list = new LinkedList<>();\n       
Sadly me neither\n```\nclass Solution {\n    long mod = (int) 1e9 + 7;\n    public int numOfWays(int[] nums) {\n        List<Integer> list = new LinkedList<>();\n        for(int i:nums){\n            list.add(i);\n        }\n\n        return (int)(((helper(list)-1)%mod) % mod);\n    }\n    \n    private long helper(List<Integer> list){\n        if(list.size() == 0 || list.size() == 1) return 1;\n        \n        int root = list.get(0);\n        List<Integer> bigger = new LinkedList<>();\n        List<Integer> smaller = new LinkedList<>();\n\n        for(int i:list){\n            if(i > root){\n                bigger.add(i);\n            }\n            if(i < root){\n                smaller.add(i);\n            }\n        }\n        int n = list.size();\n        int left = smaller.size();\n        long temp = (fac(n-1) / (fac(left)));\n        temp = temp/fac(n-1-left);\n        \n        return (temp * helper(smaller) * helper(bigger));\n    }\n    \n    private long fac(int n){\n        long res = 1;\n        while(n > 1){\n            res = res * n;\n            n--;\n        }\n        return res;\n    }\n}
[]