1362. Closest Divisors Medium

@problem@discussion
#Math



1/**
2 * [1362] Closest Divisors
3 *
4 * Given an integer num, find the closest two integers in absolute difference whose product equals num + 1 or num + 2.
5 * Return the two integers in any order.
6 *  
7 * Example 1:
8 * 
9 * Input: num = 8
10 * Output: [3,3]
11 * 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.
12 * 
13 * Example 2:
14 * 
15 * Input: num = 123
16 * Output: [5,25]
17 * 
18 * Example 3:
19 * 
20 * Input: num = 999
21 * Output: [40,25]
22 * 
23 *  
24 * Constraints:
25 * 
26 * 	1 <= num <= 10^9
27 * 
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/closest-divisors/
32// discuss: https://leetcode.com/problems/closest-divisors/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37    pub fn closest_divisors(num: i32) -> Vec<i32> {
38        vec![]
39    }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46    use super::*;
47
48    #[test]
49    fn test_1362() {
50    }
51}
52


Back
© 2025 bowen.ge All Rights Reserved.