You are not logged in. Please login at to post your questions!


Need help with a Coding Contest Problem

A Prime Array is an array which doesn't contain a pair of numbers whose product isn't a square of an integer.

For eg [1,2,3] is a Prime Array but [1,2,4] is not.

Explanation : 1*4 gives 4 which is square of 2.

Given an array of integers determine the minimum number of operations to convert the array to a Prime array.

NOTE: An operation consists of either increasing or decreasing any element of the array by 1 but the element should always be positive.

Constraints: Length of array <=100

1 <=Each integer in array <=1000000

Eg. Array => [1,1,2]

Minimum operations to convert [1,1,2] to [1,2,3] is 2.

asked 19 Nov '18, 03:31

anm_coder's gravatar image

accept rate: 0%

edited 19 Nov '18, 03:36

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 19 Nov '18, 03:31

question was seen: 234 times

last updated: 19 Nov '18, 03:36