Programming Exercises

Write a component that parses a hardcoded HTML-like string and displays the tag hierarchy.

Hard

Problem 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;
Log in or sign up to run or submit your code.Log inSign up
Input
String: '<div><p>Hello</p></div>'
Expected Output
Tag Hierarchy: ['div', 'p']