954. Array of Doubled Pairs Medium
1/**
2 * [954] Array of Doubled Pairs
3 *
4 * Given an integer array of even length arr, return true if it is possible to reorder arr such that arr[2 * i + 1] = 2 * arr[2 * i] for every 0 <= i < len(arr) / 2, or false otherwise.
5 *
6 * Example 1:
7 *
8 * Input: arr = [3,1,3,6]
9 * Output: false
10 *
11 * Example 2:
12 *
13 * Input: arr = [2,1,2,6]
14 * Output: false
15 *
16 * Example 3:
17 *
18 * Input: arr = [4,-2,2,-4]
19 * Output: true
20 * Explanation: We can take two groups, [-2,-4] and [2,4] to form [-2,-4,2,4] or [2,4,-2,-4].
21 *
22 *
23 * Constraints:
24 *
25 * 2 <= arr.length <= 3 * 10^4
26 * arr.length is even.
27 * -10^5 <= arr[i] <= 10^5
28 *
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/array-of-doubled-pairs/
33// discuss: https://leetcode.com/problems/array-of-doubled-pairs/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38 pub fn can_reorder_doubled(arr: Vec<i32>) -> bool {
39 false
40 }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 #[test]
50 fn test_954() {
51 }
52}
53
Back
© 2025 bowen.ge All Rights Reserved.