
Asked in Grey Orange
Bit Set Problem Statement
You are provided with a string, termed as DIGIT_PATTERN
, which consists solely of digits. The objective is to identify the first digit that repeats in the sequence. If there's no repeating digit, the result should be -1.
Example:
Input:
123456325
Output:
3
Explanation:
In the given string 123456325
, as we move from left to right, digit '3' is the first to repeat, making it our answer.
Constraints:
1 <= T <= 10
1 <= |DIGIT_PATTERN| <= 10^5
0 <= DIGIT_PATTERN[i] <= 9
Note:
You do not need to print anything; just return the answer for each test case.

AnswerBot
4mo
Identify the first repeating digit in a given string of digits.
Iterate through the string and keep track of seen digits using a set.
Return the first digit that repeats, or -1 if no digit repeats.
Time ...read more
Help your peers!
Add answer anonymously...
Interview Questions Asked to Software Engineer at Other Companies
Top Skill-Based Questions for Grey Orange Software Engineer
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
Software Development Interview Questions and Answers
250 Questions
SQL 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

