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.
- Maximize count of 0s in left and 1s in right substring by splitting given Binary string
- Split numeric, alphabetic and special symbols from a String
- Extract maximum numeric value from a given string | Set 1 (General approach)
- Python Regex to extract maximum numeric value from a string
- Extract maximum numeric value from a given string | Set 2 (Regex approach)
- Minimum circular rotations to obtain a given numeric string by avoiding a set of given strings
- Mobile Numeric Keypad Problem
- Count number of substrings with numeric value greater than X
- Minimum Cost to make two Numeric Strings Identical
- Count Uppercase, Lowercase, special character and numeric values
- Convert a sentence into its equivalent mobile numeric keypad sequence
- String slicing in Python to check if a string can become empty by recursive deletion
- String Range Queries to find the number of subsets equal to a given String
- Create a new string by alternately combining the characters of two halves of the string in reverse
- Find the longest sub-string which is prefix, suffix and also present inside the string | Set 2
Improved By : manishshaw1