Geeksforgeeks

Error

×

Leaderboard

Showing:

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

@Ibrahim Nash | 6420 |

@blackshadows | 6380 |

@mb1973 | 5646 |

@Quandray | 5233 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4716 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3413 |

Complete Leaderboard | |

Handle | Score |

@skj7 | 671 |

@gurshehzadsingh | 418 |

@swastik8750 | 411 |

@nishunishuraj18 | 405 |

@vedantvalsangkar | 390 |

@deepakchowdary | 380 |

@akashverma4 | 369 |

@satyamannsm | 353 |

@2018uec1603 | 333 |

@rkrupeshkumar345 | 331 |

@surajmamgai | 330 |

Complete Leaderboard |

Given a string str containing alphanumeric characters. The task is to calculate the sum of all the numbers present in the string.

**Example 1:**

**Input:
**str = 1abc23
**Output: **24**
Explanation: **1 and 23 are numbers in the
string which is added to get the sum as
24.

**Example 2:**

**Input:
**str = geeks4geeks
**Output: **4**
Explanation: **4 is the only number, so the
sum is 4.

**Your Task:**

The task is to complete the function **findSum()** which finds and returns the sum of numbers in the string.

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

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

**Constraints:**

1 <= length of the string <= 10^{5}

Sum of Numbers <= 10^{5}

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
Sum of numbers in string

...