Java stringbuilder O(n) 100% faster and space
\n\n  class Solution {\n    public String entityParser(String text) {\n        \n        if(text==null || text.length()==0)\n            return "";\n        \n 
```\n\n  class Solution {\n    public String entityParser(String text) {\n        \n        if(text==null || text.length()==0)\n            return "";\n        \n        Map<String, String> map = new HashMap();\n        map.put("&quot;", "\\"");\n        map.put("&apos;", "\'");\n        map.put("&amp;", "&");\n        map.put("&gt;", ">");\n        map.put("&lt;", "<");\n        map.put("&frasl;", "/");\n        \n        StringBuilder ans = new StringBuilder();\n        \n        int start=0, deleteStart=0, i=0;\n        \n        while(i<text.length()) {\n            \n            ans.append(text.charAt(i));\n        \n            if(text.charAt(i)==\'&\') {\n                start=i;\n                deleteStart=ans.length()-1;\n            }  else if(text.charAt(i)==\';\' && map.containsKey(text.substring(start, i+1))) {\n                    ans.replace(deleteStart, ans.length(), map.get(text.substring(start, i+1)));\n            } \n             ++i;\n        }\n        \n        return ans.toString();  \n    }\n}\n```
['String', 'Java']