最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網 會員登陸 & 注冊

LeetCode 1362. Closest Divisors

2023-08-14 12:41 作者:您是打尖兒還是住店呢  | 我要投稿

Given an integer?num, find the closest two integers in absolute difference whose product equals?num + 1?or?num + 2.

Return the two integers in any order.

?

Example 1:

Input: num = 8

Output: [3,3]

Explanation: For num + 1 = 9, the closest divisors are 3 & 3, for num + 2 = 10, the closest divisors are 2 & 5, hence 3 & 3 is chosen.

Example 2:

Input: num = 123

Output: [5,25]

Example 3:

Input: num = 999

Output: [40,25]

?

Constraints:

  • 1 <= num <= 10^9


Hide Hint 1

Find the divisors of n+1 and n+2.

Hide Hint 2

To find the divisors of a number, you only need to iterate to the square root of that number.


Runtime:?6 ms, faster than?82.52%?of?Java?online submissions for?Closest Divisors.

Memory Usage:?40.3 MB, less than?28.16%?of?Java?online submissions for?Closest Divisors.

--------------------------------------

依次遍歷即可:

下面是代碼:


LeetCode 1362. Closest Divisors的評論 (共 條)

分享到微博請遵守國家法律
镇坪县| 建始县| 通城县| 巴彦县| 太仓市| 梅河口市| 井陉县| 邯郸市| 福贡县| 乡城县| 田东县| 莱州市| 牡丹江市| 新竹县| 弥渡县| 菏泽市| 宁武县| 嘉义市| 阿巴嘎旗| 渭南市| 江安县| 新沂市| 临夏县| 郓城县| 平罗县| 林州市| 阿城市| 扶绥县| 三台县| 永城市| 洛阳市| 元谋县| 桐乡市| 桐梓县| 福贡县| 瑞昌市| 莎车县| 桐庐县| 扶风县| 乌兰察布市| 饶阳县|