simple C++ sol with explaination || faster than 80%
We are basically storing the number of elements that are smaller and larger to the left of a particular element in an array dp.\nif in an array  ith element is 
We are basically storing the number of elements that are smaller and larger to the left of a particular element in an array dp.\nif in an array  ith element is greater than jth element then the number of triplets would be the number of elements less than the jth elements.\nsame would be the case for the decreasing subsequences\n\n```\nclass Solution {\npublic:\n    int numTeams(vector<int>& rating) {\n        vector<vector<int>> dp(rating.size(),vector<int>(2,0));\n        //dp[i][0] indicates the number of elements that are less than rating[i] to left\n        //dp[i][1] indicates the number of elements that are greater tha rating[i]\n        //to left\n        int res=0;\n        for(int i=0;i<rating.size();i++){\n            for(int j=0;j<i;j++){\n                if(rating[i]>rating[j]){\n                    dp[i][0]++;\n                    res+=dp[j][0];\n                }\n                else{\n                    dp[i][1]++;\n                    res+=dp[j][1];\n                }\n            }\n        }\n        return res;\n    }\n};\n```\n\n**If you like my explaination please do upvote!.It supports me to post more solutions for you**
['Array']