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
19h

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...
Grey Orange Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
Awards 2025
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits
Stay ahead in your career with AmbitionBox app