3000. 对角线最长的矩形的面积
3000. 对角线最长的矩形的面积
题目链接:3000. 对角线最长的矩形的面积
代码如下:
class Solution {
public:int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {double maxDiagonalLength = 0;int res = 0;for (vector<int>& dimension : dimensions) {int h = dimension[0];int w = dimension[1];if (maxDiagonalLength < sqrt(h * h + w * w) ||(maxDiagonalLength == sqrt(h * h + w * w) && res < h * w)) {maxDiagonalLength = sqrt(h * h + w * w);res = h * w;}}return res;}
};