PERFECT SQUARE asked by MountainBlue
Perfect Square
Problem Statement
You're given an array A of size N, the task is to remove all the elements from the array except perfect squares of any integer and print the updated ay For example, if the given array is 9 12 16. Here, 9 and 16 are the perfect square of numbers 3 and 4 respectively. After removing others from the the t
Input Format:
The input consists of two lines:
The first line contains an integer N denoting the size of an array A. The second line contains N integers separated by space denoting elements of the array A. The input will be read from the STDIN by the candidate
Output Format:
Print the updated array with each element separated by space, if the updated array is empty then print -1.
The output will benatched to the candidate's output printed on the STDOUT
Constraints:
1< N < 500
• 1< A; S 50000
Example:
Input:
100 256 421 867 308
Output
100 256
Explanation:
Initially, the array was 100 256 421 867 308. As 100 and 256 are the perfect square of 10 and 16 respectively, we removed all the numbers from the array except
connect with me on
code is in c++
ReplyDelete