Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6420 |

@blackshadows | 6380 |

@mb1973 | 5642 |

@Quandray | 5233 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4610 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3413 |

Complete Leaderboard | |

Handle | Score |

@sanskar94511 | 603 |

@akashverma4 | 363 |

@swastik8750 | 300 |

@nishunishuraj18 | 286 |

@surajmamgai | 264 |

@anks9013 | 222 |

@nayan2709 | 213 |

@burhanuddinbohra72 | 212 |

@realname | 203 |

@amank8975 | 203 |

@manmeetkaur18102000 | 202 |

Complete Leaderboard |

Given a number **N **such that it may contain many continuous digits. Find the 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.

**Example 1:**

**Input:**
**N** **=** 100
**Output:**
2
**Explanation:**
The number 100 has only 2 possibilities,
1) one zero zero
2) one double zero.

**Example 2:**

Input:N=11112Output:8Explanation:1 1 1 1 2, 11 1 1 2, 1 1 11 2, 1 11 1 2, 11 11 2, 1 111 2, 111 1 2, 1111 2

**Example 3:**

**Input:**
**N** **=** 12345
**Output:**
1
**Explanation:**
The number 12345 has only 1 possibility,
one two three four five

**Your Task:**

You don't need to read input or print anything. Your task is to complete the function **differentWaysToSpell()** which takes a **String N **as input and returns the number of possible ways.

**Expected Time Complexity:** O(|N|)

**Expected Auxiliary Space:** O(1)

**Constraints:**

1 <= |N| <= 10^{50}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Spell a Number

...