Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

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

Try your code in this preview. Submit marks it done.

import React from "react";
 
 const ParseHTMLTags = () => {
  return (
  <div>
  {/* Display the tag hierarchy */}
  </div>
  );
 };
 
 export default ParseHTMLTags;