Skip to content

2264. Largest 3-Same-Digit Number in String #2051

Answered by mah-shamim
mah-shamim asked this question in Q&A
Discussion options

You must be logged in to vote

We need to find the largest 3-digit substring in a given string of digits where all three digits are the same. The solution involves checking for the presence of such substrings in descending order of digit values, from '999' down to '000'. The first substring found in this order will be the largest possible good integer.

Approach

  1. Problem Analysis: The task is to find a substring of length 3 in the input string where all three characters are identical. The solution should return the largest such substring if multiple exist. The largest substring is determined by the digit value (e.g., '999' is larger than '888').
  2. Intuition: By checking substrings from the highest possible digit ('999') d…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@basharul-siddike
Comment options

@mah-shamim
Comment options

mah-shamim Aug 14, 2025
Maintainer Author

Answer selected by basharul-siddike
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested easy Difficulty
2 participants