Delete Nodes Using BS and sort algo
IntuitionPrimarily, I wanted to go through LL and check the value using iterator and when I implementeded the code and submit it I did not consider the time com
# Intuition
Primarily, I wanted to go through LL and check the value using iterator and when I implementeded the code and submit it I did not consider the time complexity of iterator (O(N)), so I decided to use binary search.

# Approach
1. Iterate through the linked list and check if each value is in nums
2. If it is, I check all possible cases (head, nodes between the start and end, and the last node). For each case, I use different approaches.
3. Otherwise, I move to the next node.

For finding node->val I used bs to decrease overall time complexity.

# Complexity
- Time complexity:
O(NlogN)

# Code
```cpp []
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
    bool bs(vector<int>& nums, int target){
        int low = 0, high = nums.size() - 1;
        while (low <= high) {
            int middle = (high + low) / 2;
            if (nums[middle] == target) return true;
            else if (nums[middle] < target) low = middle + 1;
            else high = middle - 1;
        }
        return false;
    }
    ListNode* modifiedList(vector<int>& nums, ListNode* head) {
        sort(nums.begin(), nums.end());
        ListNode* curr = head;
        ListNode* prev = nullptr;
        while (curr != nullptr) {
            if (bs(nums, curr->val)) {
                if (prev == nullptr) {
                    head = curr->next;
                    curr = head;
                }
                else {
                    prev->next = curr->next;
                    curr = prev->next;
                }
            }
            else {
                prev = curr;
                curr = curr->next;
            }
        }

        return head;
    }
};
```
['Binary Search', 'Sorting', 'C++']