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!
Select
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
Grey Orange Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

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

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
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