{"id":"615a899b-3001-40a5-9c01-ce224ab290ee","name":"Remove Primes","description":"<p>1. You are given an ArrayList of positive integers. 2. You have to remove prime numbers from the given ArrayList and return the updated ArrayList. Note -&gt; The order of elements should remain same.</p>","inputFormat":"<p>A number N arr1 arr2.. N numbers</p>","outputFormat":"<p>An Arraylist</p>","constraints":"<p>1 &lt;= N &lt;= 10000</p>","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<vector>\nusing namespace std;\n\nvoid removeprimes(vector<int> v)\n{\n //write your code here\n}\nint main()\n{\n int n;\n cin>>n;\n vector<int> v(n,0);\n for(int i=0;i<n;i++)\n {\n cin>>v[i];\n }\n removeprimes(v);\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static void solution(ArrayList<Integer> al){\r\n\t\t// write your code here\r\n\t\t\r\n\t}\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tint n = scn.nextInt();\r\n\t\tArrayList<Integer> al = new ArrayList<>();\r\n\t\tfor(int i = 0 ; i < n; i++){\r\n\t\t\tal.add(scn.nextInt());\r\n\t\t}\r\n\t\tsolution(al);\r\n\t\tSystem.out.println(al);\r\n\t}\r\n\r\n}"},"python":{"code":"def solution(al):\n #write your code here\n\n\nn=int(input())\nal=[]\nal = list(map(int, input().split()))\nsolution(al)\nprint(al)"}},"points":10,"difficulty":"easy","sampleInput":"4\r\n3 12 13 15","sampleOutput":"[12, 15]","questionVideo":"https://www.youtube.com/embed/jj90JZ_wLoo?end=251","hints":[],"associated":[{"id":"8f38b210-49d8-4d40-927b-af60bebe0d5e","name":"What is the space complexity of the program?","slug":"what-is-the-space-complexity-of-the-program","type":4},{"id":"dc88fa9b-857d-4fd2-9853-a0065f3a30bd","name":"Which method is faster to remove primes?","slug":"which-method-is-faster-to-remove-primes","type":4}],"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":"28c4c414-93fc-4aa0-84dc-1c7e08313cdc","name":"String, Dynamic String and Dynamic Array","slug":"string-dynamic-string-and-dynamic-array","type":0},{"id":"7a461c32-ffe8-449c-9b3e-94c12783383d","name":"Remove Primes","slug":"remove-primes","type":1}],"next":{"id":"18a9bf5c-b7b0-4836-9ff9-e32104f7b668","name":"Print All Permutations Of A String Iteratively","type":1,"slug":"print-all-permutations-of-a-string-iteratively"},"prev":{"id":"8e88c7cb-1b77-4dfa-ba1c-021c256a78b2","name":"String With Difference Of Every Two Consecutive Characters","type":1,"slug":"string-with-difference-of-every-two-consecutive-characters"}}}

Remove Primes

<p>1. You are given an ArrayList of positive integers. 2. You have to remove prime numbers from the given ArrayList and return the updated ArrayList. Note -&gt; The order of elements should remain same.</p>

{"id":"615a899b-3001-40a5-9c01-ce224ab290ee","name":"Remove Primes","description":"<p>1. You are given an ArrayList of positive integers. 2. You have to remove prime numbers from the given ArrayList and return the updated ArrayList. Note -&gt; The order of elements should remain same.</p>","inputFormat":"<p>A number N arr1 arr2.. N numbers</p>","outputFormat":"<p>An Arraylist</p>","constraints":"<p>1 &lt;= N &lt;= 10000</p>","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<vector>\nusing namespace std;\n\nvoid removeprimes(vector<int> v)\n{\n //write your code here\n}\nint main()\n{\n int n;\n cin>>n;\n vector<int> v(n,0);\n for(int i=0;i<n;i++)\n {\n cin>>v[i];\n }\n removeprimes(v);\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static void solution(ArrayList<Integer> al){\r\n\t\t// write your code here\r\n\t\t\r\n\t}\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tint n = scn.nextInt();\r\n\t\tArrayList<Integer> al = new ArrayList<>();\r\n\t\tfor(int i = 0 ; i < n; i++){\r\n\t\t\tal.add(scn.nextInt());\r\n\t\t}\r\n\t\tsolution(al);\r\n\t\tSystem.out.println(al);\r\n\t}\r\n\r\n}"},"python":{"code":"def solution(al):\n #write your code here\n\n\nn=int(input())\nal=[]\nal = list(map(int, input().split()))\nsolution(al)\nprint(al)"}},"points":10,"difficulty":"easy","sampleInput":"4\r\n3 12 13 15","sampleOutput":"[12, 15]","questionVideo":"https://www.youtube.com/embed/jj90JZ_wLoo?end=251","hints":[],"associated":[{"id":"8f38b210-49d8-4d40-927b-af60bebe0d5e","name":"What is the space complexity of the program?","slug":"what-is-the-space-complexity-of-the-program","type":4},{"id":"dc88fa9b-857d-4fd2-9853-a0065f3a30bd","name":"Which method is faster to remove primes?","slug":"which-method-is-faster-to-remove-primes","type":4}],"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":"28c4c414-93fc-4aa0-84dc-1c7e08313cdc","name":"String, Dynamic String and Dynamic Array","slug":"string-dynamic-string-and-dynamic-array","type":0},{"id":"7a461c32-ffe8-449c-9b3e-94c12783383d","name":"Remove Primes","slug":"remove-primes","type":1}],"next":{"id":"18a9bf5c-b7b0-4836-9ff9-e32104f7b668","name":"Print All Permutations Of A String Iteratively","type":1,"slug":"print-all-permutations-of-a-string-iteratively"},"prev":{"id":"8e88c7cb-1b77-4dfa-ba1c-021c256a78b2","name":"String With Difference Of Every Two Consecutive Characters","type":1,"slug":"string-with-difference-of-every-two-consecutive-characters"}}}
plane

Editor


Loading...

Remove Primes

easy

1. You are given an ArrayList of positive integers. 2. You have to remove prime numbers from the given ArrayList and return the updated ArrayList. Note -> The order of elements should remain same.

Constraints

1 <= N <= 10000

Format

Input

A number N arr1 arr2.. N numbers

Output

An Arraylist

Example

Sample Input

4 3 12 13 15

Sample Output

[12, 15]

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode