Last active
April 30, 2025 21:30
-
-
Save Elviselly2/90d9a1d8874e601f60a7ea6dda2e7163 to your computer and use it in GitHub Desktop.
Pseudocode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN | |
FUNCTION HTMLElements(str) | |
DEFINE validTags AS ["b", "i", "em", "div", "p"] | |
CREATE an empty stack | |
FOR each character in str | |
IF it is an opening tag THEN | |
PUSH it onto the stack | |
ELSE IF it is a closing tag THEN | |
IF stack is empty THEN | |
RETURN the mismatched closing tag | |
ELSE | |
POP top element from the stack | |
IF popped element does not match current closing tag THEN | |
RETURN the mismatched opening tag | |
END IFs | |
IF stack is empty THEN | |
RETURN "true" | |
ELSE | |
RETURN the first unmatched opening tag | |
END FUNCTION | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is my gist on stuck