343. Integer Break Medium
1/**
2 * [343] Integer Break
3 *
4 * Given an integer n, break it into the sum of k positive integers, where k >= 2, and maximize the product of those integers.
5 * Return the maximum product you can get.
6 *
7 * Example 1:
8 *
9 * Input: n = 2
10 * Output: 1
11 * Explanation: 2 = 1 + 1, 1 × 1 = 1.
12 *
13 * Example 2:
14 *
15 * Input: n = 10
16 * Output: 36
17 * Explanation: 10 = 3 + 3 + 4, 3 × 3 × 4 = 36.
18 *
19 *
20 * Constraints:
21 *
22 * 2 <= n <= 58
23 *
24 */
25pub struct Solution {}
26
27// problem: https://leetcode.com/problems/integer-break/
28// discuss: https://leetcode.com/problems/integer-break/discuss/?currentPage=1&orderBy=most_votes&query=
29
30// submission codes start here
31
32impl Solution {
33 pub fn integer_break(n: i32) -> i32 {
34 0
35 }
36}
37
38// submission codes end
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43
44 #[test]
45 fn test_343() {
46 }
47}
48
Back
© 2025 bowen.ge All Rights Reserved.