`{"id":"2330f29d-5bdf-43df-a18d-48f250af164b","name":"Double Pair Array","description":"1. You are given an array(arr) of integers with even length N.\r\n2. You have to tell if it is possible to re-order the given array such that for every i in range [0,N/2)\r\n arr[2*i + 1] = 2 * arr[2*i], this condition holds true.","inputFormat":"A number N\r\narr1\r\narr2.. N numbers","outputFormat":"true/false","constraints":"1 &lt;= N &lt;= 10^4\r\n-10^5 &lt;= arr[i] &lt;= 10^5","sampleCode":{"cpp":{"code":"#include <bits/stdc++.h>\nusing namespace std;\n\n\nbool solution(vector<int>& arr) {\n //write your code here\n\n}\n\n\n\nint main()\n{\n int n;\n cin >> n;\n vector<int>arr(n, 0);\n for (int i = 0; i < n; i++)\n {\n cin >> arr[i];\n };\n\n bool ans = solution(arr);\n if (ans == 1) {\n cout << \"true\";\n }\n else {\n cout << \"false\";\n }\n return 0;\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static int solution(int[] arr) {\r\n // write your code here\r\n \r\n return 0;\r\n }\r\n \r\n public static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tint n = scn.nextInt();\r\n\t\tint[] arr = new int[n];\r\n\t\tfor(int i = 0 ; i < n; i++){\r\n\t\t\tarr[i] = scn.nextInt();\r\n\t\t}\r\n\t\tSystem.out.println(solution(arr));\r\n\t}\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"4\r\n3 1 3 6","sampleOutput":"false\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"ec6515dc-6811-4c65-912f-0134b65df120","name":"HashMap and Heap For Intermediate","slug":"hashmap-and-heap-for-intermediate-10002","type":0},{"id":"61715ec3-7c4e-4e5e-bd75-f8873ee02d86","name":"Double Pair Array","slug":"double-pair-array","type":1}],"next":{"id":"4818782e-f0dd-454b-baf3-3b91536a2ada","name":"Double Pair Array MCQ","type":0,"slug":"double-pair-array-mcq"},"prev":{"id":"348c9951-89db-4e2b-98b6-95b6e7e3a068","name":"Rabbits In The Forest","type":3,"slug":"rabbits-in-the-forest"}}}`

# Double Pair Array

1. You are given an array(arr) of integers with even length N. 2. You have to tell if it is possible to re-order the given array such that for every i in range [0,N/2) arr[2*i + 1] = 2 * arr[2*i], this condition holds true.

`{"id":"2330f29d-5bdf-43df-a18d-48f250af164b","name":"Double Pair Array","description":"1. You are given an array(arr) of integers with even length N.\r\n2. You have to tell if it is possible to re-order the given array such that for every i in range [0,N/2)\r\n arr[2*i + 1] = 2 * arr[2*i], this condition holds true.","inputFormat":"A number N\r\narr1\r\narr2.. N numbers","outputFormat":"true/false","constraints":"1 &lt;= N &lt;= 10^4\r\n-10^5 &lt;= arr[i] &lt;= 10^5","sampleCode":{"cpp":{"code":"#include <bits/stdc++.h>\nusing namespace std;\n\n\nbool solution(vector<int>& arr) {\n //write your code here\n\n}\n\n\n\nint main()\n{\n int n;\n cin >> n;\n vector<int>arr(n, 0);\n for (int i = 0; i < n; i++)\n {\n cin >> arr[i];\n };\n\n bool ans = solution(arr);\n if (ans == 1) {\n cout << \"true\";\n }\n else {\n cout << \"false\";\n }\n return 0;\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static int solution(int[] arr) {\r\n // write your code here\r\n \r\n return 0;\r\n }\r\n \r\n public static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tint n = scn.nextInt();\r\n\t\tint[] arr = new int[n];\r\n\t\tfor(int i = 0 ; i < n; i++){\r\n\t\t\tarr[i] = scn.nextInt();\r\n\t\t}\r\n\t\tSystem.out.println(solution(arr));\r\n\t}\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"4\r\n3 1 3 6","sampleOutput":"false\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"ec6515dc-6811-4c65-912f-0134b65df120","name":"HashMap and Heap For Intermediate","slug":"hashmap-and-heap-for-intermediate-10002","type":0},{"id":"61715ec3-7c4e-4e5e-bd75-f8873ee02d86","name":"Double Pair Array","slug":"double-pair-array","type":1}],"next":{"id":"4818782e-f0dd-454b-baf3-3b91536a2ada","name":"Double Pair Array MCQ","type":0,"slug":"double-pair-array-mcq"},"prev":{"id":"348c9951-89db-4e2b-98b6-95b6e7e3a068","name":"Rabbits In The Forest","type":3,"slug":"rabbits-in-the-forest"}}}` Editor

# Double Pair Array

medium

1. You are given an array(arr) of integers with even length N. 2. You have to tell if it is possible to re-order the given array such that for every i in range [0,N/2) arr[2*i + 1] = 2 * arr[2*i], this condition holds true.

## Constraints

1 <= N <= 10^4 -10^5 <= arr[i] <= 10^5

## Format

### Input

A number N arr1 arr2.. N numbers

true/false

## Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}4 3 1 3 6```

### Sample Output

```.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}false ```

Discussions

Show Discussion

Related Resources 