Java O(N) solution  with O(N) space. self explanatory code..beats 100%
\n  public String entityParser(String text) {\n\n        char[] arr = text.toCharArray();\n        List<Integer> position = new ArrayList<>();\n        for(int 
```\n  public String entityParser(String text) {\n\n        char[] arr = text.toCharArray();\n        List<Integer> position = new ArrayList<>();\n        for(int i=0;i<arr.length;i++){\n            if( arr[i] == \'&\') position.add(i);\n        }\n        // now we process all the &nds;\n\n        for( int x : position){\n            StringBuilder str = new StringBuilder(7);\n            int i=0;\n            for(i=1;i<7 && x+i < arr.length ;i++){\n                if(arr[x+i]==\';\'){\n                    String s = str.toString();\n                    switch(s){\n                        case "quot": {\n                            arr[x] = \'"\';\n                            for( int j=1;j<=5;j++) arr[x+j]=(char)0;\n                            break;\n                        }\n                        case "apos":{\n                            arr[x] = \'\\\'\';\n                            for( int j=1;j<=5;j++) arr[x+j]=(char)0;\n                            break;\n                        }\n                        case "amp":{\n                            arr[x] = \'&\';\n                            for( int j=1;j<=4;j++) arr[x+j]=(char)0;\n                            break;\n                        }\n                        case "gt":{\n                            arr[x] = \'>\';\n                            for( int j=1;j<=3;j++) arr[x+j]=(char)0;\n                            break;\n                        }\n                        case "lt":{\n                            arr[x] = \'<\';\n                            for( int j=1;j<=3;j++) arr[x+j]=(char)0;\n                            break;\n                        }\n                        case "frasl":{\n                            arr[x] = \'/\';\n                            for( int j=1;j<=6;j++) arr[x+j]=(char)0;\n                            break;\n                        }\n                        default:{\n\n                        }\n                    }\n                }else{\n                    str.append(arr[x+i]);\n                }\n            }\n        }\n        //rebuild the string\n        int l=0;\n        for(int i=0;i<arr.length;i++){\n            if(arr[i] != (char)0){\n                arr[l] = arr[i];\n                l++;\n            }\n        }\n        return new String(arr,0,l);\n    }\n```\n
[]