Given a numeric string (length <= 32), split it into two or more integers( if possible), such that
1) Difference between current and previous number is 1.
2) No number contains leading zeroes
If it is possible to separate a given numeric string then print “Possible” followed by the first number of the increasing sequence, else print “Not Possible“.
Input : 1234 Output : Possible 1 Explanation: String can be split as "1", "2", "3", "4" Input : 99100 Output :Possible 99 Explanation: String can be split as "99", "100" Input : 101103 Output : Not Possible Explanation: It is not possible to split this string under given constraint.
Approach : The idea is to take a substring from index 0 to any index i (i starting from 1) of the numeric string and convert it to long data type. Add 1 to it and convert the increased number back to string. Check if the next occurring substring is equal to the increased one. If yes, then carry on the procedure else increase the value of i and repeat the steps.
- Extract maximum numeric value from a given string | Set 2 (Regex approach)
- Split numeric, alphabetic and special symbols from a String
- Python Regex to extract maximum numeric value from a string
- Extract maximum numeric value from a given string | Set 1 (General approach)
- Mobile Numeric Keypad Problem
- Count number of substrings with numeric value greater than X
- Minimum Cost to make two Numeric Strings Identical
- Convert a sentence into its equivalent mobile numeric keypad sequence
- Count Uppercase, Lowercase, special character and numeric values
- Find the longest sub-string which is prefix, suffix and also present inside the string
- Lexicographically smallest string formed by appending a character from first K characters of a string | Set 2
- Find the longest sub-string which is prefix, suffix and also present inside the string | Set 2
- Create a new string by alternately combining the characters of two halves of the string in reverse
- Minimal moves to form a string by adding characters or appending string itself
- String slicing in Python to check if a string can become empty by recursive deletion
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : manishshaw1