C++ :: using accumulate (to reduce) | Runtime - beats 94.70% | Memory - beats 99.59%
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nUsed std::accumulate to reduce the rectangles\n\n# Complexity\n- Time com
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nUsed std::accumulate to reduce the rectangles\n\n# Complexity\n- Time complexity: O(n)\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```cpp []\nclass Solution {\npublic:\n    int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {\n        using Area = std::size_t;\n        using PoweredDiagonalLength = std::size_t;\n        using RetType = std::pair<Area, PoweredDiagonalLength>;\n\n        RetType ret = std::accumulate(dimensions.begin(), dimensions.end(), RetType{},\n                    [](RetType ret, vector<int>& rectangle)\n                    {\n                        PoweredDiagonalLength pdl = (rectangle[0U] * rectangle[0U]) + (rectangle[1U] * rectangle[1U]);\n                        Area a = rectangle[0U] * rectangle[1U];\n\n                        if (ret.second < pdl)\n                        {\n                            return RetType{std::move(a), std::move(pdl)};\n                        }\n\n                        if (ret.second == pdl)\n                        {\n                            return ret.first > a ? std::move(ret) : RetType{std::move(a), std::move(pdl)}; \n                        }\n\n                        return std::move(ret);\n                    });\n\n        return ret.first;\n    }\n};\n```
['C++']