Given a String str, the task is to check the sum of ASCII values of all characters in this string is a perfect cube or not.
Input: str = "ll" Output: Yes ASCII value of l = 108 Therefore, sum of ASCII values = 108 + 108 = 216 which is a perfect cube 6 (6 * 6 * 6 = 216) Input: str = "a" Output: No ASCII value of a = 97 Therefore, sum of ASCII values = 97 which is not a perfect cube
- For each character in the String, find out its ASCII value
- Calculate sum of ASCII values of all characters
- Check whether this sum is a perfect cube or not.
- If the sum is a perfect cube, then print “Yes” otherwise “No”
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Count numbers upto N which are both perfect square and perfect cube
- Percentage increase in volume of the cube if a side of cube is increased by a given percentage
- Count all triplets whose sum is equal to a perfect cube
- Perfect cube greater than a given number
- Largest number in an array that is not a perfect cube
- Largest perfect cube number in an Array
- Smallest perfect Cube divisible by all elements of an array
- Smallest perfect cube in an array
- Print N numbers such that their sum is a Perfect Cube
- Number of times the largest Perfect Cube can be subtracted from N
- Minimum divisor of a number to make the number perfect cube
- Least number to be added to or subtracted from N to make it a Perfect Cube
- Check whether N can be a Perfect Cube after adding or subtracting K
- Count of pairs in an Array whose sum is a Perfect Cube
- Perfect Cube
- Check if number formed by joining two Numbers is Perfect Cube
- Print N numbers such that their product is a Perfect Cube
- Previous perfect square and cube number smaller than number N
- Construct an Array of size N whose sum of cube of all elements is a perfect square
- Construct an Array such that cube sum of all element is a perfect square
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.