• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
December 09, 2023 |1.2K Views

PROBLEM OF THE DAY : 08/12/2023 | Transform to prime

Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Arrays but also build up problem-solving skills.

In this problem, we are given, an array of n integers. Find the minimum positive number to be inserted in the array, so that the sum of all elements of the array becomes prime.

Example :

Input:
N=5
arr = {2, 4, 6, 8, 12}
Output:  
5

Explanation: 
The sum of the array is 32, we can add 5 to this to make it 37 which is a prime number

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/transform-to-prime4635/1
Solution IDE Link: https://ide.geeksforgeeks.org/online-cpp-compiler/26320440-e4b9-4660-9a87-cf11826e35de