leetcode[Construct the Rectangle]//待整理多种解法
来源:互联网 发布:javascript写网页 编辑:程序博客网 时间:2024/05/21 17:11
解法一:
public class Solution { public int[] constructRectangle(int area) { int length = (int) Math.ceil(Math.sqrt(area));//从平方根开始分界,求出长度的最大可能值 boolean isFind = true; int[] res = new int[2]; while(isFind){ if(area % length == 0){ res[0] = length; res[1] = area / length; return res; } else{ length++; } } return res; }}
阅读全文
0 0
- leetcode[Construct the Rectangle]//待整理多种解法
- leetcode[Construct String from Binary Tree]//待整理多种解法
- leetcode[Find the Difference]//待整理多种解法
- leetcode[Reshape the Matrix]//待整理多种解法
- leetcode [Path Sum]//待整理多种解法
- leetcode [Majority Element]//待整理多种解法
- leetcode [Rotate Array]//待整理多种解法
- leetcode [Reverse Bits]//待整理多种解法
- leetcode [Happy Number]//待整理多种解法
- leetcode [Isomorphic Strings]//待整理多种解法
- leetcode [Contains Duplicate]//待整理多种解法
- leetcode[Add Digits]//待整理多种解法
- leetcode[Ugly Number]//待整理多种解法
- leetcode[Missing Number]//待整理多种解法
- leetcode[Word Pattern]//待整理多种解法
- leetcode[Ransom Note]//待整理多种解法
- leetcode[Longest Palindrome]//待整理多种解法
- leetcode[Fizz Buzz]//待整理多种解法
- 使用高德地图的api获取所在城市
- 浅谈引用<三> C++中指针和引用的区别
- UVALive 7146-贪心&数据结构stl-Defeat the Enemy
- 二叉树实现机制
- HDU6073-Matching In Multiplication
- leetcode[Construct the Rectangle]//待整理多种解法
- Ubuntu相关资料
- C/C++混合编程
- 2.A 张成空间与线性无关
- S3C2451嵌入式简介
- 万能 Makefile 模板
- CSRF verification failed. Request aborted
- spring整合mybatis
- hdu 1698 Just a Hook (线段树区间更新+懒惰标记)