
Missing Number in Concatenated Sequence
You were given a sequence of consecutive nonnegative integers but missed one while appending them to create a string S
. Your task is to identify the missing integer from this sequence.
If it is possible to form a sequence of consecutive integers by identifying the missing integer, then return that number. If the string is incorrectly formed with more than one missing integer, no missing integer, or the string is invalid, return -1.
Example:
Input:
T = 1
S = "1113"
Output:
12
Explanation:
The sequence was 11, 12, 13, but 12 was missed, leading to the string "1113".
Constraints:
- 1 <= T <= 100
- 1 <= |S| <= 104
- The string
S
consists of digits 0 to 9 - Numbers in the sequence have no more than six digits
- Time Limit: 1 second
Note:
Ensure your solution correctly identifies the missing number or determines when to output -1.


The task is to find the missing number in a string of consecutive nonnegative integers.
Iterate through the string and check if each substring can form a valid number
If a substring forms a valid number...read more

Top Amazon Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Top HR questions asked in Amazon Software Developer Intern
Reviews
Interviews
Salaries
Users/Month