3000. 对角线最长的矩形的面积

3000. 对角线最长的矩形的面积


题目链接:3000. 对角线最长的矩形的面积

代码如下:

cpp 复制代码
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;
	}
};
相关推荐
第七序章8 分钟前
【C + +】红黑树:全面剖析与深度学习
c语言·开发语言·数据结构·c++·人工智能
夜晚中的人海11 分钟前
【C++】滑动窗口算法习题
开发语言·c++·算法
AA陈超35 分钟前
虚幻引擎5 GAS开发俯视角RPG游戏 P06-09 玩家等级与战斗接口
c++·游戏·ue5·游戏引擎·虚幻
·白小白1 小时前
力扣(LeetCode) ——118.杨辉三角(C++)
c++·算法·leetcode
tongsound1 小时前
libmodbus 使用示例
linux·c++
sulikey1 小时前
C++的STL:深入理解 C++ 的 std::initializer_list
开发语言·c++·stl·list·initializerlist·c++标准库
代大大1 小时前
sciter.js 之cpp使用教程(1)
c++·前端框架
仰泳的熊猫1 小时前
LeetCode:207. 课程表
数据结构·c++·算法·leetcode
liu****2 小时前
19.map和set的封装
开发语言·数据结构·c++·算法
孤廖2 小时前
C++ 模板再升级:非类型参数、特化技巧(含全特化与偏特化)、分离编译破解
linux·服务器·开发语言·c++·人工智能·后端·深度学习