FEST06 - Editorial

Problem Link:
[CONTEST][1]
[PRACTICE][3]

Author- [Virender Yadav][4]

Tester- [Vipin Khushu][2]

Editorialist- [Virender Yadav][4]

Difficulty:
Simple

Prerequisites:
Math,Easy

Problem:
We have given a string of numbers and words . Our task is to find sum of all number in the string.

Explantion:
As the size of string is 10^5.
So the most biggest size of integer can be of length 10^5 , we have to use array to store integer value inside string.
Take two array b,c of size equal to length of given string a. One to store an integer at any place in string and second to store sum.
The concept behinde this is that store first integer inside string in an array b and sum it with array c and empty array b, so the sum gets stored in c and now store next integer in b.
Traverse a loop in string a, check if a[i] is in an integer so put it in array b at last position and if in next time when i increments a[i] is an integer put that in second last position else sum both array b and c and empty array b.
Sum array b and c once again at the end of loop because if the last element is integer it also gets in sum.
Now check if the array C is with 0 or empty if empty print “-1” else print the sum stored inside it.

Solution:
http://ideone.com/ZxBj4F
[1]: https://www.codechef.com/CDWR2016/problems/FEST06
[2]: http://www.codechef.com/users/vipinkhushu
[4]: http://www.codechef.com/users/viru1404
[5]: http://www.codechef.com/users/vipinkhushu
[3]: https://www.codechef.com/problems/FEST06

very easy problem

wow its awesome