![]() |
VOOZH | about |
Given a String str and the task is to check sum of ASCII value of all characters is a perfect square or not.
Examples :
Input : ddddddddddddddddddddddddd
Output : YesInput : GeeksForGeeks
Output : No
Algorithm
- Calculate the string length
- Calculate sum of ASCII value of all characters
- Take the square root of the number sum and store it into variable squareRoot
- Take floor value of the squareRoot and subtract from squareRoot
- If the difference of floor value of squareRoot and squareRoot is 0 then print "Yes" otherwise "No"
Below is the implementation of the above approach :
Yes
Time Complexity: O(len), where the len is the length of the string.
Auxiliary Space: O(1)