Perfect Cube String | C ++ program to find if string is a perfect cube or not . ; Finding ASCII values of each character and finding its sum ; Find the cube root of sum ; Check if sum is a perfect cube ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isPerfectCubeString ( string str ) { int sum = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) sum += ( int ) str [ i ] ; long double cr = round ( cbrt ( sum ) ) ; return ( cr * cr * cr == sum ) ; } int main ( ) { string str = " ll " ; if ( isPerfectCubeString ( str ) ) cout << " Yes " ; else cout << " No " ; }