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.

Be the first one to answer
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