Get TLE anyone help
\n\n\t\n\t class Solution {\n    long dval=Long.MIN_VALUE;\n    String ans="";\n    boolean dowork=true;\n    public String maximumBinaryString(String binary) {
\n\n\t\n\t class Solution {\n    long dval=Long.MIN_VALUE;\n    String ans="";\n    boolean dowork=true;\n    public String maximumBinaryString(String binary) {\n        Set<String> set=new HashSet<>();\n           explore(binary,0,set);\n             return ans;\n             }\n    \n            public void explore(String binary,int index,Set<String> set){\n              if(index==binary.length()){\n                  return;\n              }\n                if(set.contains(binary)){\n                    return;\n                }\n        long nval=valuecheck(binary);\n                set.add(binary);\n                \n                if(dval<nval){\n                    dval=nval;\n                    ans=binary;\n                }\n            for(int i=0;i<binary.length()-1;i++){\n           String check=binary.substring(i,i+2);\n            if(check.compareTo("00")==0){\n            String leftstring=binary.substring(0,i)+"10";\n            String rightstring=binary.substring(i+2);\n                String newstring=leftstring+rightstring;\n               \n                explore(newstring,i+1,set);\n            }else if(check.compareTo("10")==0){\n                  String leftstring=binary.substring(0,i)+"01";\n            String rightstring=binary.substring(i+2);\n                String newstring=leftstring+rightstring;\n                explore(newstring,i+1,set);\n            }\n                  }\n    }\n    public  long valuecheck(String binary){\n        if(binary==null)\n            return 0;\n        long number=Long.parseLong(binary,2);\n        long sum=0;\n        long count=0;\n        while(number>0){\n            long num=number%10;\n            sum=sum+num*(long)(Math.pow(2,count++));\n            number=number/10;\n        }\n        return sum;\n    }}
[]