mirror of
				https://github.com/KieSun/all-of-frontend.git
				synced 2025-05-29 01:49:23 +08:00 
			
		
		
		
	feat: removeElements
This commit is contained in:
		
							parent
							
								
									d41dfad254
								
							
						
					
					
						commit
						70516c9818
					
				@ -0,0 +1,15 @@
 | 
			
		||||
var removeElements = function(head, val) {
 | 
			
		||||
    const dummy = new ListNode()
 | 
			
		||||
    let node = dummy
 | 
			
		||||
    while (head) {
 | 
			
		||||
        const tmp = head.next
 | 
			
		||||
        if (head.val !== val) {
 | 
			
		||||
            node.next = head
 | 
			
		||||
            node = head
 | 
			
		||||
        }
 | 
			
		||||
        head = tmp
 | 
			
		||||
    }
 | 
			
		||||
    node.next = null
 | 
			
		||||
    return dummy.next
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user