Why my java solution exceeds time limits?


  • 0
    R
                StringBuffer sb1 = new StringBuffer();
                StringBuffer sb2 = new StringBuffer();
                while(head!=null){
    		sb1 = sb1.append(head.val);
    		sb2 = sb2.insert(0, head.val);
    		head = head.next;
    	}
    	if(sb1.toString().equals(sb2.toString())){
    		return true;
    	}else{
    		return false;
    	}

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.