# info2021-homework1 ###### tags: `資訊科技產業面試` contributed by <`bochengC> ### 總體初步檢討 #### 對interviewee 1. 不知道該如何問出延伸的問題,如何跟實務有連接 2. 用英文的時候,會明顯有斷點,無法連續輸出 3. 對語法不熟,`struct` 的分號,在結束後才想到 4. 無法用語言具體的有邏輯的將想法敘述出來 5. 不該照抄Leetcode的程式碼,應該直接如以下寫法 ```c++= sturct ListNode{}; NodeList* function_name(ListNode* ){ }...... ``` 不用在那邊public之類的 #### 對interviewer 1. 詞彙不足,不知道怎麼跟interviewee互動 2. 沒辦法跟interviewee 討論想法 ### easy1 1290. Convert Binary Number in a Linked List to Integer :red_square: :white_large_square: : ```c++= struct ListNode{ int val; ListNode* next; }; class Solution { public: int getDecimalValue(ListNode* head) { int sum = 0 ; ListNode* pointer= head; while(pointer != NULL){ sum = sum *2 ; sum = sum + pointer->val; pointer= pointer->next; } return sum; } }; ``` ### easy2 1474. Delete N Nodes After M Nodes of a Linked List ```c++= class Solution { public: ListNode* deleteNodes(ListNode* head, int m, int n) { ListNode* pointer=head; int remove = n; int keep = m-1 ; while(pointer != NULL){ if(keep != 0){ pointer = pointer->next; keep--; }else if(remove != 0){ if(pointer->next == NULL) break; pointer->next = pointer->next->next; remove--; }else{ keep = m; remove = n ; } } return head; } }; ``` ### medium 1669. Merge In Between Linked Lists ```c++= class Solution { public: ListNode* mergeInBetween(ListNode* list1, int a, int b, ListNode* list2) { ListNode *head, *tmp; head = list1 ; a--; while(a>0){ list1 = list1->next; a--; b--; } tmp = list1; while(b> 0){ tmp = tmp->next; b--; } list1 ->next = list2 ; while(list2->next){ list2 = list2->next; } list2->next = tmp->next; return head; } }; ```