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...
Popular interview questions of Software Engineer
A Software Engineer was asked Q1. Bit Set Problem Statement You are provided with a string, termed as DIGIT_PATTER...read more
A Software Engineer was asked Q2. Rectangle Area Calculation Given a list of rectangles, where each rectangle is r...read more
A Software Engineer was asked Q3. Print All Permutations of a String Given an input string STR, generate and print...read more
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

