2095. javascript의 Leetcode 솔루션
/**
 * Definition for singly-linked list.
 * function ListNode(val, next) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.next = (next===undefined ? null : next)
 * }
 */
/**
 * @param {ListNode} head
 * @return {ListNode}
 */
const deleteMiddle = function(head) {
  if(head == null) return head
  const dummy = new ListNode(null, head)
  let n = 0, cur = head
  while(cur) {
    n++
    cur = cur.next
  }
  if(n === 1) return null
  const mid = Math.floor(n / 2)
  cur = dummy.next
  let pre = dummy 
  for(let i = 0; i < n; i++) {
    if(i === mid - 1) {
      pre = cur
      // pre.next = cur.next.next
    }
    if(i === mid) {
      pre.next = cur.next
    }
    if(i > mid) break
    cur = cur.next
  }
  return dummy.next
};
 도전 리트코드
다음은 문제에 대한 링크입니다: https://leetcode.com/problems/delete-the-middle-node-of-a-linked-list/
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(2095. javascript의 Leetcode 솔루션), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://dev.to/chiki1601/2095-leetcode-solution-in-1cmb
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
다음은 문제에 대한 링크입니다: https://leetcode.com/problems/delete-the-middle-node-of-a-linked-list/
Reference
이 문제에 관하여(2095. javascript의 Leetcode 솔루션), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/chiki1601/2095-leetcode-solution-in-1cmb텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)