PAT-A 1074 Reversing Linked List (25)

  翻转链表,注意有不在链表上的结点。

Given a constant $K$ and a singly linked list L, you are supposed to reverse the links of every $K$ elements on $L$. For example, given L being 1→2→3→4→5→6, if $K=3$, then you must output 3→2→1→6→5→4; if $K=4$, you must output 4→3→2→1→5→6.

PAT-A 1133 Splitting A Linked List (25)

  又是链表,又是段错误。

Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all the values in [0, K] appear before all those greater than K. The order of the elements inside each class must not be changed. For example, given the list being 18 → 7 → -4 → 0 → 5 → -6 → 10 → 11 → -2 and K being 10, you must output -4 → -6 → -2 → 7 → 0 → 5 → 10 → 18 → 11.

PAT-A 1097 Deduplication on a Linked List (25)

  链表操作。出现段错误。

Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value or absolute value of its key equals K will be kept. At the mean time, all the removed nodes must be kept in a separate list. For example, given L being 21 → -15 → -15 → -7 → 15, you must output 21 → -15 → -7, and the removed list -15 → 15.

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×