Write a component that parses a hardcoded HTML-like string and displays the tag hierarchy.
HardProblem Statement
Write a component that parses a hardcoded HTML-like string and displays the tag hierarchy.
Sample Input
String: '<div><p>Hello</p></div>'
Sample Output
Tag Hierarchy: ['div', 'p']
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
import React from "react";
const ParseHTMLTags = () => {
return (
<div>
{/* Display the tag hierarchy */}
</div>
);
};
export default ParseHTMLTags;
Input
String: '<div><p>Hello</p></div>'
Expected Output
Tag Hierarchy: ['div', 'p']