Dsa
Recursion
Easy
XML Tag Counter
Create a program that counts the number of tags in a simple XML structure represented as a string. The XML may contain nested tags. Your program should read a string from the input and output the total number of unique tags found. Ensure to ignore nested tags for counting and only account for the outermost tags.
Example Input:
<root><tag1><tag2></tag2></tag1><tag3></tag3></root>
Example Output:
3
Key concepts
recursiontreestring manipulation
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