一、CRC冗余码
二、双向链表的插入
p之后插入s
s->next = p->next; s->prior = p; p->next = s; p->next->prior = s;
三、栈实现括号匹配
public boolean isValid(String s){ Stack<Character> stack = new Stack<Character>(); for(char c : s.toCharArray()){ if(c == '(') stack.push(')'); if(c == '[') stack.push(']'); if(c == '{') stack.push('}'); if(stack.isEmpty() || c!=stack.pop()) return false; } return stack.isEmpty(); }
四、手写双向链表
// 二、双端链表 class DoubleLinked { private Node head, tail;//头结点和尾结点 private int size;//链表的元素数目 public DoubleLinked() { head = new Node(0, 0); tail = new Node(0, 0); head.next = tail; tail.prev = head; size = 0; } // 在头部插入node结点 public void addFirst(Node x) { x.prev = head; x.next = head.next; head.next.prev = x; head.next = x; size++; } // 移除指定结点 public void remove(Node x) { x.prev.next = x.next; x.next.prev = x.prev; size--; } // 删除链表的第一个结点,并返回该结点 public Node removeLast() { if(head.next == tail) return null;//返回空 Node last = tail.prev; remove(last);//删除尾结点; return last; } public int size() { return size; } }

