Tap here to switch tabs
Problem
Submissions

Problem: Longest Nice Substring

med
30 min
Try to solve the Longest Nice Substring problem.

Statement

A string is defined as nice if, for every letter of the alphabet contained in the string, both its uppercase and lowercase forms are present.

Given a string s, return the longest substring of s that is nice. If there are multiple nice substrings of the maximum length, return the one with the earliest starting index. If no nice substring exists, return an empty string "".

Constraints:

  • 1≤s.length≤1001 \le s.length \le 100

  • s consists of uppercase and lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Longest Nice Substring

med
30 min
Try to solve the Longest Nice Substring problem.

Statement

A string is defined as nice if, for every letter of the alphabet contained in the string, both its uppercase and lowercase forms are present.

Given a string s, return the longest substring of s that is nice. If there are multiple nice substrings of the maximum length, return the one with the earliest starting index. If no nice substring exists, return an empty string "".

Constraints:

  • 1≤s.length≤1001 \le s.length \le 100

  • s consists of uppercase and lowercase English letters.