lleetcode (1) 썸네일형 리스트형 Remove Nth Node From End of List, LeetCode, c++/cpp/c 1. 첫 번째 코드 class Solution { public: ListNode* removeNthFromEnd(ListNode* head, int n) { int cnt = 1; ListNode* from = new ListNode(); from->next = head; ListNode remove = *head; while (remove.next) { remove = *remove.next; cnt++; } remove = *from; for (int i = 0; i next and n != cnt) tmp->next = tmp->next->next; else head = head->next; return head; } }; Colored by Color Scripter cs 2. 2. 완성한 코드 .. 이전 1 다음