2834. Find the Minimum Possible Sum of a Beautiful Array Medium
1/**
2 * [2834] Find the Minimum Possible Sum of a Beautiful Array
3 *
4 * You are given positive integers n and target.
5 * An array nums is beautiful if it meets the following conditions:
6 *
7 * nums.length == n.
8 * nums consists of pairwise distinct positive integers.
9 * There doesn't exist two distinct indices, i and j, in the range [0, n - 1], such that nums[i] + nums[j] == target.
10 *
11 * Return the minimum possible sum that a beautiful array could have modulo 10^9 + 7.
12 *
13 * <strong class="example">Example 1:
14 *
15 * Input: n = 2, target = 3
16 * Output: 4
17 * Explanation: We can see that nums = [1,3] is beautiful.
18 * - The array nums has length n = 2.
19 * - The array nums consists of pairwise distinct positive integers.
20 * - There doesn't exist two distinct indices, i and j, with nums[i] + nums[j] == 3.
21 * It can be proven that 4 is the minimum possible sum that a beautiful array could have.
22 *
23 * <strong class="example">Example 2:
24 *
25 * Input: n = 3, target = 3
26 * Output: 8
27 * Explanation: We can see that nums = [1,3,4] is beautiful.
28 * - The array nums has length n = 3.
29 * - The array nums consists of pairwise distinct positive integers.
30 * - There doesn't exist two distinct indices, i and j, with nums[i] + nums[j] == 3.
31 * It can be proven that 8 is the minimum possible sum that a beautiful array could have.
32 *
33 * <strong class="example">Example 3:
34 *
35 * Input: n = 1, target = 1
36 * Output: 1
37 * Explanation: We can see, that nums = [1] is beautiful.
38 *
39 *
40 * Constraints:
41 *
42 * 1 <= n <= 10^9
43 * 1 <= target <= 10^9
44 *
45 */
46pub struct Solution {}
47
48// problem: https://leetcode.com/problems/find-the-minimum-possible-sum-of-a-beautiful-array/
49// discuss: https://leetcode.com/problems/find-the-minimum-possible-sum-of-a-beautiful-array/discuss/?currentPage=1&orderBy=most_votes&query=
50
51// submission codes start here
52
53impl Solution {
54 pub fn minimum_possible_sum(n: i32, target: i32) -> i32 {
55 0
56 }
57}
58
59// submission codes end
60
61#[cfg(test)]
62mod tests {
63 use super::*;
64
65 #[test]
66 fn test_2834() {
67 }
68}
69
Back
© 2025 bowen.ge All Rights Reserved.