SIMPLE AND EASY SOLUTION
Complexity\n- Time complexity: O(N^3)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n# 
# Complexity\n- Time complexity: O(N^3)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int numTeams(vector<int>& rating) {\n        int n = rating.size();\n        int count = 0;\n\n        for (int i = 0; i < n; ++i) {\n            for (int j = i + 1; j < n; ++j) {\n                for (int k = j + 1; k < n; ++k) {\n                    if ((rating[i] < rating[j] && rating[j] < rating[k]) ||\n                        (rating[i] > rating[j] && rating[j] > rating[k])) {\n                        count++;\n                    }\n                }\n            }\n        }\n        \n        return count;\n    }\n};\n\n```
['Array', 'C++']