11package g1401_1500 .s1410_html_entity_parser ;
22
3- // #Medium #String #Hash_Table #2022_03_26_Time_41_ms_(73.12%)_Space_72.8_MB_(20.43 %)
3+ // #Medium #String #Hash_Table #2022_03_26_Time_15_ms_(98.92%)_Space_42.6_MB_(100.00 %)
44
55public class Solution {
66 public String entityParser (String text ) {
@@ -10,22 +10,22 @@ public String entityParser(String text) {
1010 if (text .charAt (i ) != '&' ) {
1111 sb .append (text .charAt (i ));
1212 } else {
13- if (i + 7 <= text .length () && text . substring ( i , i + 7 ). equals ( "⁄" )) {
13+ if (text .startsWith ( "⁄" , i )) {
1414 sb .append ("/" );
1515 i += 6 ;
16- } else if (i + 6 <= text .length () && text . substring ( i , i + 6 ). equals ( """ )) {
16+ } else if (text .startsWith ( """ , i )) {
1717 sb .append ("\" " );
1818 i += 5 ;
19- } else if (i + 6 <= text .length () && text . substring ( i , i + 6 ). equals ( "'" )) {
19+ } else if (text .startsWith ( "'" , i )) {
2020 sb .append ("'" );
2121 i += 5 ;
22- } else if (i + 5 <= text .length () && text . substring ( i , i + 5 ). equals ( "&" )) {
22+ } else if (text .startsWith ( "&" , i )) {
2323 sb .append ("&" );
2424 i += 4 ;
25- } else if (i + 4 <= text .length () && text . substring ( i , i + 4 ). equals ( ">" )) {
25+ } else if (text .startsWith ( ">" , i )) {
2626 sb .append (">" );
2727 i += 3 ;
28- } else if (i + 4 <= text .length () && text . substring ( i , i + 4 ). equals ( "<" )) {
28+ } else if (text .startsWith ( "<" , i )) {
2929 sb .append ("<" );
3030 i += 3 ;
3131 } else {
0 commit comments