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
Given a string of consecutive nonnegative integers without separators, find the missing integer.
Iterate through all possible splits of the string and check if the sequence is valid
If the sequence is v...read more
Help your peers!
Add answer anonymously...
Hike Android Developer interview questions & answers
An Android Developer was asked 12mo agoQ. What are the different Android components and concepts such as RecyclerView, Vie...read more
An Android Developer was asked 12mo agoQ. Design and implement a Least Recently Used (LRU) cache. It should support the fo...read more
An Android Developer was asked 12mo agoQ. How would you debug and resolve a crash and ANR given a stack trace?
Popular interview questions of Android Developer
An Android Developer was asked 12mo agoQ1. What are the different Android components and concepts such as RecyclerView, Vie...read more
An Android Developer was asked 12mo agoQ2. Design and implement a Least Recently Used (LRU) cache. It should support the fo...read more
An Android Developer was asked Q3. Design an ImageDownloader that efficiently handles parallel API calls.
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

