Concatenated Square?
Problem Statement
Constraints
1 ≤ a, b ≤ 100
a and b are integers.
Approach:
So in this problem what we can do - we have given the two integer numbers, first we have to do the concatenation of these numbers. After that we have to find the square root of concatenated number. If this number is a square of any number then we have to print Yes else we have to print No. That means that number is not a square of any number.
Lets take one example.
We have given two integers a=1 and b=21, Now we have to do the concatenation of these numbers.
So concatenation of a and b is = 121, now we have to check if this 121 is a square of any number or Not. 121 is the square of 11 so we can print Yes
So to solve this problem will take two numbers a and b as inputs in string format. Now will do the concatenation of given number after that we have to find the square root of this number. So we find the square root of this concatenated number using Math.sqrt() function. If we get the number in integer format that means we can say that this number is a square root of a number.
Solution:-
Java Code:-
C++ Code:-
JavaScript Code:-
Python Code:-
Thank you for taking time to see the article. I have provided solutions in C++, Java, JavaScript, and Python languages. If you are interested then you can try that as well.
If you like this article, Please like, share and follow our blog to see such posts.
No comments: