
Asked in Amazon
Find Missing Number In String Problem Statement
You have a sequence of consecutive nonnegative integers. By appending all integers end-to-end, you formed a string S
without any separators. During this process, you accidentally omitted exactly one integer from the sequence. Given the string, your task is to find the missing integer.
If there is more than one missing integer, if all integers are present, or if the string is invalid, return -1.
Example:
Input:
S = "1113"
Output:
12
Explanation:
The sequence 11, 12, 13 without one integer forms "1113" by missing 12.
Input:
T
S
Output:
Missing number for each test case
Constraints:
1 <= T <= 100
1 <= |S| <= 10^4
0 <= S[i] <= 9
Note:
The numbers will have no more than six digits and consist of digits 0 to 9 only.

AnswerBot
4mo
Find the missing number in a string of consecutive nonnegative integers.
Iterate through the string and check for missing numbers by comparing adjacent integers
If a missing number is found, return it a...read more
Help your peers!
Add answer anonymously...
Top Software Developer Interview Questions Asked at Amazon
Q. Could you describe the process for designing a data structure that allows for al...read more
Q. What is Java?
Q. What is PHP?
Interview Questions Asked to Software Developer at Other Companies
Top Skill-Based Questions for Amazon Software Developer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

