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;
	}
};
相关推荐
澈2074 小时前
深入浅出C++滑动窗口算法:原理、实现与实战应用详解
数据结构·c++·算法
A.A呐4 小时前
【C++第二十九章】IO流
开发语言·c++
ambition202424 小时前
从暴力搜索到理论最优:一道任务调度问题的完整算法演进历程
c语言·数据结构·c++·算法·贪心算法·深度优先
kebeiovo4 小时前
atomic原子操作实现无锁队列
服务器·c++
Yungoal4 小时前
常见 时间复杂度计算
c++·算法
6Hzlia4 小时前
【Hot 100 刷题计划】 LeetCode 48. 旋转图像 | C++ 矩阵变换题解
c++·leetcode·矩阵
Ricky_Theseus5 小时前
C++右值引用
java·开发语言·c++
吴梓穆6 小时前
UE5 c++ 常用方法
java·c++·ue5
云栖梦泽6 小时前
Linux内核与驱动:9.Linux 驱动 API 封装
linux·c++
Morwit6 小时前
【力扣hot100】 1. 两数之和
数据结构·c++·算法·leetcode·职场和发展