Dsa
Stack
Hard
HTML Tag Balancing
You are given a string containing HTML tags. Your task is to check if the HTML tags are properly nested and balanced. An HTML tag is defined as a start tag '<tag>' and an end tag '</tag>'. A well-formed HTML string has every start tag properly closed in the reverse order they were opened. Write a program to determine if the provided HTML string is balanced. Output 'Yes' if it is balanced or 'No' otherwise.
Input Format:
A single line string containing HTML tags.
Output Format:
'Yes' if balanced, 'No' if not.
Example:
Input:
<div><span></span></div>
Output:
Yes
Key concepts
stackhtmltag
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