Today I was given this interview question. Can someone please help me with the solutions?
/**
* Return the sum of all integers from a random string. Continuous Integers must be considered as one number.
* Given the following inputs, we expect the corresponding output:
*
* "1a2b3c" ==>6 (1+2+3)
* "123ab!45c" ==> 168 (123+45)
* "abcdef" ==> 0 (no integers in String)
* "0123.4" ==> 127 (0123+4)
* "dFD$#23++++12@#T1234;/..10" => 1279 (23+12+1234+10)
* "12a-10b" => 2 (12-10)
*/
private static long SumOfNumbers (String str){
return null;
Aucun commentaire:
Enregistrer un commentaire