Dsa
Two Pointers
Easy
Balanced String Brackets
Given a string of brackets, determine the longest substring that contains balanced brackets. Balanced brackets are defined as pairs of '()' or '[]'.
Input Format:
The first line contains a single integer n, the length of the string.
The second line contains the string composed of characters '()', '[]'.
Output Format:
Print the length of the longest balanced substring.
Example:
Input:
8
([]())[]
Output:
8
Key concepts
two_pointersstrings
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now