Tap here to switch tabs
Problem
Submissions

Problem: Longest Nice Substring

Longest Nice Substring asks you to find the longest substring where each letter appears in both uppercase and lowercase forms. Ties go to the earliest start; return an empty string if none exists.

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

Longest Nice Substring asks you to find the longest substring where each letter appears in both uppercase and lowercase forms. Ties go to the earliest start; return an empty string if none exists.

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.