Geeksforgeeks Solution For " Different ways to Spell a Number "

GeeksforGeeks Solution For Hard Domain .Below You Can Find The Solution Of  School Basic ,Easy ,Medium . Or Hackerrank Solution You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers 

Problem :- Given a  number. The number may contain many same continuous digits in it. The task is to count number of ways to spell the number.
For example, consider 8884441100, one can spell it simply as triple eight triple four double two and double zero. One can also spell as double eight, eight, four, double four, two, two, double zero.

Submit Your Solution :- Click Here 

Solution :- 

using namespace std;
typedef long long int ll;

ll spellsCount(string num)
    int n = num.length();
    ll result = 1;
    for (int i=0; i<n; i++)
       int count = 1;
       while (i < n-1 && num[i+1] == num[i])
       result = result * pow(2, count-1);
    return result;

int main()
int t;
    string num ;
    cout << spellsCount(num);
    return 0;


Geeksforgeeks Solution For " Different ways to Spell a Number "

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment