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;
	}
};
相关推荐
txinyu的博客3 小时前
解析业务层的key冲突问题
开发语言·c++·分布式
SmartRadio4 小时前
ESP32添加修改蓝牙名称和获取蓝牙连接状态的AT命令-完整UART BLE服务功能后的完整`main.c`代码
c语言·开发语言·c++·esp32·ble
charlie1145141916 小时前
嵌入式的现代C++教程——constexpr与设计技巧
开发语言·c++·笔记·单片机·学习·算法·嵌入式
CSDN_RTKLIB9 小时前
【字符编码】有无BOM的UTF-8
c++
Chary20169 小时前
opengl 学习资料路径
c++·opengl
im_AMBER10 小时前
Leetcode 102 反转链表
数据结构·c++·学习·算法·leetcode·链表
今儿敲了吗10 小时前
01|多项式输出
c++·笔记·算法
程序员Jared10 小时前
C++11—mutex
c++
朔北之忘 Clancy10 小时前
2025 年 9 月青少年软编等考 C 语言一级真题解析
c语言·开发语言·c++·学习·数学·青少年编程·题解
量子炒饭大师11 小时前
【C++入门】Cyber底码作用域的隔离协议——【C++命名空间】(using namespace std的原理)
开发语言·c++·dubbo