✅✅ Beats 100% !! Easy to understand C++ solution.
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem requires finding the rectangle with the maximum diagonal length and, in cas
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem requires finding the rectangle with the maximum diagonal length and, in case of a tie, returning the one with the maximum area. \nTo achieve this, we need to calculate the diagonal length for each rectangle and compare it with the current maximum diagonal length. \nIf the diagonal length is greater or equal (in case of a tie), we update the maximum diagonal length and check if the area of the current rectangle is greater than the maximum area. If so, we update the maximum area as well.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nInitialize two variables, diag and area, to keep track of the maximum diagonal length and area encountered during the iteration.\n\nIterate through each rectangle in the input array.\n\nFor each rectangle, calculate the square of the diagonal length using the formula  \n(d[0] * d[0] + d[1] * d[1])\n\nCompare the calculated diagonal length (t) with the current maximum diagonal length (diag).\n\n- If t is greater than diag, update both diag and area.\n- If t is equal to diag and the product of the rectangle\'s length and width (d[0]*d[1]) is greater than the current maximum area (area), update area.\n\nAfter iterating through all rectangles, the maximum area will be stored in the area variable.\n\nReturn the maximum area.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nThe time complexity of the provided solution is O(N), where N is the number of rectangles in the input array.\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nThe space complexity is O(1) because the algorithm uses a constant amount of space regardless of the size of the input\n\n# Code\n```\nclass Solution {\npublic:\n    int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {\n        \n        int diag = 0;\n        int area = 0;\n\n        for(auto d : dimensions){\n\n            int t = d[0]*d[0] + d[1]*d[1];\n\n            if(t>diag || (t == diag && d[0]*d[1] > area)){\n\n                diag = t;\n                area = d[0]*d[1]; \n            }\n        }\n\n        return area;\n    }\n};\n```
['Array', 'Math', 'C++']