| 1 | class Solution { |
| 2 | public ListNode modifiedList(int[] nums, ListNode head) { |
| 3 | boolean set[] = new boolean[(int)1e5+1]; |
| 4 | for(int num : nums){ |
| 5 | set[num] = true; |
| 6 | } |
| 7 | ListNode prev = null; |
| 8 | ListNode cur = head; |
| 9 | while(cur!=null){ |
| 10 | if(set[cur.val]==true){ |
| 11 | if(prev == null){ //del at head |
| 12 | head = head.next; |
| 13 | cur.next = null; |
| 14 | cur = head; |
| 15 | }else{ |
| 16 | prev.next = cur.next; |
| 17 | cur.next = null; |
| 18 | cur = prev.next; |
| 19 | } |
| 20 | }else{ |
| 21 | prev = cur; |
| 22 | cur = cur.next; |
| 23 | } |
| 24 | } |
| 25 | return head; |
| 26 | } |
| 27 | } |
nothing calls this directly
no outgoing calls
no test coverage detected