【例题1】2011. 执行操作后的变量值 - 力扣(LeetCode)

int finalValueAfterOperations(char ** operations, int operationsSize){
    int ans = 0;
    for(int i=0;i<operationsSize;i++){
        for(int j = 0;j <= 2;j++){
            if(operations[i][j] == '+'){
                ans++;break;
            }
            if(operations[i][j] == '-'){
                ans--;break;
            }
        }
    }
    return ans;
}

【例题2】面试题 02.02. 返回倒数第 k 个节点 - 力扣(LeetCode)

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
int kthToLast(struct ListNode* head, int k){
    struct ListNode* l = head;
    struct ListNode* r = head;
    while(k-- > 0) r = r->next;
    while(r!=NULL) {
        l=l->next;r=r->next;
    }
    return l->val;
}

【例题3】19. 删除链表的倒数第 N 个结点 - 力扣(LeetCode)

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
struct ListNode* removeNthFromEnd(struct ListNode* head, int n){
    if(head->next == NULL) return NULL;
    struct ListNode* O = head;
    struct ListNode* L = head;
    struct ListNode* R = head;
    for(int i=1;i<=n;i++) R=R->next;
    if(R == NULL) return head->next;
    while(R->next!=NULL){
        L=L->next;R=R->next;
    }
    L->next = L->next->next;
    return O;
}

【例题4】206. 反转链表 - 力扣(LeetCode)

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */

struct ListNode* reverseList(struct ListNode* head){
    if(!head) return NULL;
    if(head->next == NULL) return head;
    struct ListNode* L = head;
    struct ListNode* M = L->next;
    if(M->next == NULL) {
        L->next = NULL;
        M->next = L;
        return M;
    }
    struct ListNode* R = M->next;
    L->next = NULL;
    while(R!=NULL){
        M->next = L;
        L = M;
        M = R;
        R = R->next;
    }
    M->next = L;
    return M;
}

【例题5】237. 删除链表中的节点 - 力扣(LeetCode)

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
void deleteNode(struct ListNode* node) {
    struct ListNode* O = node;
    struct ListNode* L = node;
    struct ListNode* R = node->next;
    while(R->next!=NULL){
        L->val = R->val;
        L=L->next;
        R=R->next;
    }
    L->val = R->val;
    L->next = NULL;
}