Back to course home
0% completed
Solution: Longest Nice Substring
Problem Statement
Given a string str
, return the longest nice substring
of a given string.
A substring is considered nice
if for every lowercase letter in the substring, its uppercase counterpart is also present, and vice versa. Fo example "AaBbB"
is a nice string as A
and a
present, and B
and b
present.
If there are multiple, return the substring of the earliest
occurrence. If no such string exists, return an empty string.
Examples
- Example 1:
- Input:
"BbCcXxY"
- Expected Output:
"BbCcXx"
- Justification: Here, `"BbCcXx"
- Input:
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible