Extract the Number from the String
Submissions: 10578   Accuracy:


  Difficulty: Easy   Marks: 2
Associated Course(s):   Geeks Classes

Bastin once had trouble finding the numbers in a string. The numbers are distributed in a string across various test cases.
There are various numbers in each test case you need to find the number in each test case. Each test case has various numbers in sequence. You need to find only those numbers which do not contain 9. For eg, if the string contains "hello this is alpha 5051 and 9475".You will extract 5051 and not 9475. You need only those numbers which are consecutive and you need to help him find the numbers.  

Note: Use long long for storing the numbers from the string.
The first line consists of T test cases and next T lines contain a string.
For each string output the number stored in that string if various numbers are there print the largest one. If a string has no numbers print -1.

This is alpha 5057 and 97

** For More Input/Output Examples Use 'Expected Output' option **

Author: Ayush Saluja

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.