Skip to main content
LeetCode 954, Medium. Topics: Array, Hash Table, Greedy, Sorting. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 30 parametrized pytest cases, and a playground notebook:

Problem

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.

Examples

Constraints

  • 2 <= arr.length <= 3 * 10^4
  • arr.length is even.
  • -10^5 <= arr[i] <= 10^5

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

Last modified on September 7, 2026