Skip to main content
LeetCode 2264, Easy. Topics: String. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 20 parametrized pytest cases, and a playground notebook:

Problem

You are given a string num representing a large integer. An integer is good if it meets the following conditions:
  • It is a substring of num with length 3.
  • It consists of only one unique digit.
Return the maximum good integer as a string or an empty string "" if no such integer exists. Note:
  • A substring is a contiguous sequence of characters within a string.
  • There may be leading zeroes in num or a good integer.

Examples

Constraints

  • 3 <= num.length <= 1000
  • num only consists of digits.

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

NeetCode All.
Last modified on September 7, 2026