O(n) | Easy Solution with Comments (Short)
IntuitionUse a buffer curr_entity to track the current sequence. When & appears, start capturing. On ;, check for a valid entity in entity_map. If found, replac
## **Intuition**  
Use a buffer `curr_entity` to track the current sequence. When `&` appears, start capturing. On `;`, check for a valid entity in `entity_map`. If found, replace it; otherwise, append as normal text.

### Complexity
- Time complexity: O(n)
- Space complexity: O(n)

## Code
```rust []
use std::collections::HashMap;

impl Solution {
    pub fn entity_parser(text: String) -> String {
        let entity_map = HashMap::from([
            ("&quot;", "\""),
            ("&apos;", "'"),
            ("&amp;", "&"),
            ("&gt;", ">"),
            ("&lt;", "<"),
            ("&frasl;", "/"),
        ]);

        let mut result = String::new();
        let mut curr_entity = String::new();

        for chr in text.chars() {
            // If an '&' is encountered, store the current entity (if any) in the result 
            // and start capturing a new potential entity.
            if chr == '&' {
                result.push_str(&curr_entity);
                curr_entity = String::new();
            }
            
            // Add the current character to the entity buffer.
            curr_entity.push(chr);

            // If a ';' is found, check if the collected sequence is a valid entity.
            // If valid, replace it in the result; otherwise, keep it unchanged.
            if chr == ';' && entity_map.contains_key(curr_entity.as_str()) {
                result.push_str(entity_map.get(curr_entity.as_str()).unwrap());
                curr_entity = String::new(); // Reset buffer after replacement
            }
        }

        // Append any remaining text that wasn’t part of a valid entity.
        result.push_str(&curr_entity);
        result
    }
}
```
```python []
class Solution:
    def entityParser(self, text: str) -> str:
        entity_map = {
            "&quot;": "\"",
            "&apos;": "'",
            "&amp;": "&",
            "&gt;": ">",
            "&lt;": "<",
            "&frasl;": "/",
        }

        result = []
        curr_entity = []

        for char in text:
            if char == '&':
                result.extend(curr_entity)
                curr_entity = []
            
            curr_entity.append(char)

            if char == ';' and "".join(curr_entity) in entity_map:
                result.append(entity_map["".join(curr_entity)])
                curr_entity = []
        
        result.extend(curr_entity)
        return "".join(result)
```
['Hash Table', 'String', 'Python3', 'Rust']