#K48172. HTML Tag Validator
HTML Tag Validator
HTML Tag Validator
You are given a string that contains HTML-like tags. The tags are in the format of <tag>
for opening tags and </tag>
for closing tags, where tag
consists of alphanumeric characters. Your task is to determine if the tags are properly closed and nested.
The validation rules are:
- Every opening tag must have a corresponding closing tag.
- Tags must be closed in the correct order (i.e., last opened, first closed).
- Tag names are case-insensitive.
For example, the string <div><b>hello</b><i>world</i></div>
is valid, while <div><b>hello</i></b></div>
is not valid.
Mathematically, if we denote an opening tag by \( <tag> \) and closing tag by \( </tag> \), the string is valid if and only if the tags form a correct nested sequence.
inputFormat
The input consists of a single line string s which contains the HTML-like text.
Note: The input is provided via standard input (stdin).
outputFormat
Output True
if the tags are valid and properly nested, otherwise output False
.
Note: The output should be printed to standard output (stdout).
## samplehelloworld
True