1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Solution {
public ListNode removeElements(ListNode head, int val) {
if (head == null) {
return null;
}
ListNode dummy = new ListNode(0, head), prev = dummy, ptr = head;
while (ptr != null) {
if (ptr.val == val) {
prev.next = ptr.next;
ptr.next = null;
ptr = prev.next;
} else {
prev = ptr;
ptr = ptr.next;
}
}
return dummy.next;
}
}

tshark -r wireless.pcap -Y ‘((wlan.fc.type_subtype == 0x20) && (wlan.fc.protected == 1)) && (wlan.bssid == 02:00:00:00:32:00)’ -T fields -e wlan.sa|sort|uniq -c|sort -nr

很直接做就行. 引入一个sentinel node.

时间复杂度: O(n)
空间复杂度: O(1)