Simple solution beats 97%. O(N) with StringBuilder
IntuitionThe problem requires converting HTML entity encodings to their respective characters. Given that HTML entities always start with & and end with ;, we c
# Intuition  
The problem requires converting HTML entity encodings to their respective characters. Given that HTML entities always start with `&` and end with `;`, we can scan through the input string and replace known entities with their corresponding characters while preserving the rest of the text.

# Approach  
1. **Iterate through the string**: Use a loop to traverse the characters of the input string.  
2. **Check for an entity start (`&`)**: When encountering `&`, check if it matches any predefined entity (`&quot;`, `&apos;`, etc.).  
3. **Replace recognized entities**: If a match is found, append the corresponding character (`"`, `'`, `&`, `>`, `<`, `/`) to the output and skip ahead in the string.  
4. **Append unmatched characters**: If `&` is not followed by a valid entity, treat it as a regular character and append it to the result.  
5. **Return the processed string**: After parsing the entire string, return the updated version with entity replacements.  

# Complexity  
- **Time complexity**:  
  - The approach involves a single pass through the string (`O(n)`) and a constant-time lookup for each entity (`O(1)`).  
  - Thus, the overall time complexity is **O(n)**, where `n` is the length of the input string.  

- **Space complexity**:  
  - A `StringBuilder` is used to store the transformed string, which requires **O(n)** space in the worst case (if no replacements occur).  
  - Additional space usage is constant (`O(1)`) since we only store predefined entity strings.  
  - Overall, the space complexity is **O(n)**.  

# Code  
```java []
class Solution {

    private static String QUOT_STRING = "&quot;";
    private static String APOS_STRING = "&apos;";
    private static String AMP_STRING = "&amp;";
    private static String GT_STRING = "&gt;";
    private static String LT_STRING = "&lt;";
    private static String FRASL_STRING = "&frasl;";

    public String entityParser(String text) {
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < text.length(); i++) {
            char ch = text.charAt(i);
            if (ch == '&') {
                if (text.regionMatches(i, QUOT_STRING, 0, QUOT_STRING.length())) {
                    sb.append('"');
                    i += QUOT_STRING.length() - 1;
                } else if (text.regionMatches(i, APOS_STRING, 0, APOS_STRING.length())) {
                    sb.append('\'');
                    i += APOS_STRING.length() - 1;
                } else if (text.regionMatches(i, AMP_STRING, 0, AMP_STRING.length())) {
                    sb.append('&');
                    i += AMP_STRING.length() - 1;
                } else if (text.regionMatches(i, GT_STRING, 0, GT_STRING.length())) {
                    sb.append('>');
                    i += GT_STRING.length() - 1;
                } else if (text.regionMatches(i, LT_STRING, 0, LT_STRING.length())) {
                    sb.append('<');
                    i += LT_STRING.length() - 1;
                } else if (text.regionMatches(i, FRASL_STRING, 0, FRASL_STRING.length())) {
                    sb.append('/');
                    i += FRASL_STRING.length() - 1;
                } else {
                    sb.append(ch);
                }
            } else {
                sb.append(ch);
            }
        }
        return sb.toString();
    }
}

['Java']