LeetCode 分类练习(5)—— 链表相关习题(1)

力扣刷题 之 链表的成环和反转 力扣刷题讲解链表的成环和反转原理 阅读详情

206. Reverse Linked List

Reverse a singly linked list.

click to show more hints.

Hint:
A linked list can be reversed either iteratively or recursively. Could you implement both?
package com.leetcode.linked_list;


public class Reverse_Linked_List {
    // 非递归写法
//  public ListNode reverseList(ListNode head) {
//      ListNode newHead = null;
//        while(head!=null){
//            ListNode next = head.next;
//            head.next = newHead;
//            newHead = head;
//            head = next;
//        }
//        return newHead;
//  }

    // 递归写法
    public ListNode reverseList(ListNode head) {
        if (head == null || head.next == null)
            return head;

        ListNode newHead = reverseList(head.next);
        head.next.next = head;
        head.next = null;
        return newHead;
    }


}

92. Reverse Linked List II

Reverse a linked list from position m to n. Do it in-place and in one-pass.

For example:
Given 1->2->3->4->5->NULL, m = 2 and n = 4,

return 1->4->3->2->5->NULL.

Note:
Given m, n satisfy the following condition:
1 ≤ m ≤ n ≤ length of list.
package com.leetcode.linked_list;

import java.util.Arrays;

public class Reverse_Linked_List_II {
    public ListNode reverseBetween(ListNode head, int m, int n) {
        if (m == n || head == null || head.next == null)
            return head;

        ListNode dummy = new ListNode(0);
        dummy.next = head;
        ListNode pre = dummy;

        for (int i = 0; i < m - 1; i++) {
            pre = pre.next;
        }
        ListNode start = pre.next;
        ListNode then = start.next;

        for (int i = 0; i < n - m; i++) {
            start.next = then.next;
            then.next = pre.next;
            pre.next = then;
            then = start.next;
        }
        return dummy.next;
    }

//        public ListNode reverseBetween(ListNode head, int m, int n) {
//        if (head.next == null || head == null || m == n)
//            return head;
//
//        ListNode pos_n = head;
//        int pos = 1;
//        ListNode pre_m;
//        ListNode pos_m;
//        if (m != 1) {
//            pre_m = head;
//            while (pos < m - 1) {
//                pre_m = pre_m.next;
//                pos++;
//            }
//            pos_m = pre_m.next;
//        } else {
//            pre_m = null;
//            pos_m = head;
//        }
//
//
//        while (pos < n) {
//            pos_n = pos_n.next;
//            pos++;
//        }
//        ListNode after_n = pos_n.next;
//
//        if (after_n != null){
//            pos_n = pos_n.next;
//            after_n = pos_n.next;
//        }
//
//
//        ListNode newHead = after_n;
//        while (m <= n) {
//            ListNode nextNode = pos_m.next;
//            pos_m.next = newHead;
//            newHead = pos_m;
//            pos_m = nextNode;
//            m++;
//        }
//        if (pre_m != null)
//            pre_m.next = newHead;
//
//        if (pre_m == head)  // m == 2 的情况
//            return pre_m;
//
//        if (after_n == null || pre_m == null)   // 对于 m == 1 或是 n == list.length 的情况
//            return newHead;
//
//        return head;
//    }

    public static void main(String[] args) {
        LinkedListCreator creator = new LinkedListCreator();
        Reverse_Linked_List_II reverse = new Reverse_Linked_List_II();

        ListNode head = creator.createLinkedList(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 7, 5, 4, 3));
        ListNode.printLinkedList(head);
        ListNode.printLinkedList(reverse.reverseBetween(head, 3, 7));

        ListNode head_1 = creator.createLinkedList(Arrays.asList(5));
        ListNode.printLinkedList(head_1);
        ListNode.printLinkedList(reverse.reverseBetween(head_1, 1, 1));

        ListNode head_2 = creator.createLinkedList(Arrays.asList(3, 5));
        ListNode.printLinkedList(head_2);
        ListNode.printLinkedList(reverse.reverseBetween(head_2, 2, 2));

//        ListNode head_3 = creator.createLinkedList(Arrays.asList(3, 5, 6, 7, 8));
//        ListNode.printLinkedList(head_3);
//        ListNode.printLinkedList(reverse.reverseBetween(head_3, 1, 5));
//        ListNode.printLinkedList(reverse.reverseBetween(head_3, 2, 5));
//        ListNode.printLinkedList(reverse.reverseBetween(head_3, 1, 4));

        ListNode head_4 = creator.createLinkedList(Arrays.asList(1, 2, 3, 4, 5));
        ListNode.printLinkedList(head_4);
        ListNode.printLinkedList(reverse.reverseBetween(head_4, 1, 4));


    }
}

83. Remove Duplicates from Sorted List

Given a sorted linked list, delete all duplicates such that each element appear only once.

For example,
Given 1->1->2, return 1->2.
Given 1->1->2->3->3, return 1->2->3.
package com.leetcode.linked_list;

import java.util.Arrays;

public class Remove_Duplicates_from_Sorted_List_II {
    public ListNode deleteDuplicates(ListNode head) {
        if (head == null || head.next == null)
            return head;
        ListNode dummy = new ListNode(0);
        dummy.next = head;
        ListNode pre = dummy;
        ListNode cur = head;

        while (cur != null) {
            while (cur.next != null && cur.val == cur.next.val) {
                cur = cur.next;
            }
            if (pre.next == cur) {
                pre = pre.next;
            } else {
                pre.next = cur.next;
            }
            cur = cur.next;
        }
        return dummy.next;
    }

    public static void main(String[] args) {
        LinkedListCreator creator = new LinkedListCreator();
        Remove_Duplicates_from_Sorted_List_II remove = new Remove_Duplicates_from_Sorted_List_II();

//        ListNode head = creator.createLinkedList(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 7, 5, 4, 3));
        ListNode head = creator.createLinkedList(Arrays.asList(1, 1));
        ListNode.printLinkedList(remove.deleteDuplicates(head));

    }
}

86. Partition List

Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.

You should preserve the original relative order of the nodes in each of the two partitions.

For example,
Given 1->4->3->2->5->2 and x = 3,
return 1->2->2->4->3->5.
package com.leetcode.linked_list;

import java.util.Arrays;

public class Partition_List {
    public ListNode partition(ListNode head, int x) {
        ListNode dummy1 = new ListNode(0), dummy2 = new ListNode(0);  //dummy heads of the 1st and 2nd queues
        ListNode curr1 = dummy1, curr2 = dummy2;      //current tails of the two queues;
        while (head != null) {
            if (head.val < x) {
                curr1.next = head;
                curr1 = head;
            } else {
                curr2.next = head;
                curr2 = head;
            }
            head = head.next;
        }
        curr2.next = null;          //important! avoid cycle in linked list. otherwise u will get TLE.
        curr1.next = dummy2.next;
        return dummy1.next;
    }

    public static void main(String[] args) {
        LinkedListCreator creator = new LinkedListCreator();
        Partition_List partition_list = new Partition_List();

//        ListNode head = creator.createLinkedList(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 2, 1, 2));
//        ListNode.printLinkedList(head);
//        ListNode.printLinkedList(partition_list.partition(head, 3));

        ListNode head = creator.createLinkedList(Arrays.asList(1, 4, 3, 2, 5, 2));
        ListNode.printLinkedList(head);
        ListNode.printLinkedList(partition_list.partition(head, 3));
    }
}

328. Odd Even Linked List

Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.

You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity.

Example:
Given 1->2->3->4->5->NULL,
return 1->3->5->2->4->NULL.

Note:
The relative order inside both the even and odd groups should remain as it was in the input. 
The first node is considered odd, the second node even and so on ...
package com.leetcode.linked_list;

import java.util.ArrayList;
import java.util.Arrays;

public class Odd_Even_Linked_List {
    public ListNode oddEvenList(ListNode head) {
        if (head == null || head.next == null || head.next.next == null)
            return head;
        ListNode dummy1 = new ListNode(0);
        ListNode dummy2 = new ListNode(0);
        ListNode curr1 = dummy1, curr2 = dummy2;
        int pos = 1;
        while (head != null){
            if (pos % 2 == 1){
                curr1.next = head;
                curr1 = head;
            }else {
                curr2.next = head;
                curr2 = head;
            }
            head = head.next;
            pos++;
        }
        curr1.next = dummy2.next;
        curr2.next = null;
        return dummy1.next;
    }

    public static void main(String[] args) {
        LinkedListCreator creator = new LinkedListCreator();
        Odd_Even_Linked_List odd_even_linked_list = new Odd_Even_Linked_List();

//        ListNode head = creator.createLinkedList(Arrays.asList(1, 2, 3, 4, 5, 6, 7));
//        ListNode head = creator.createLinkedList(Arrays.asList(1));
//        ListNode head = creator.createLinkedList(Arrays.asList(1, 2));
        ListNode head = creator.createLinkedList(new ArrayList<>());

        ListNode.printLinkedList(head);
        ListNode.printLinkedList(odd_even_linked_list.oddEvenList(head));
    }

}

2. Add Two Numbers

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

You may assume the two numbers do not contain any leading zero, except the number 0 itself.

Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8
package com.leetcode.linked_list;

import java.util.Arrays;

public class Add_Two_Numbers {
    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
        ListNode dummy = new ListNode(0);
        ListNode cur = dummy;
        int carry = 0;
        while (l1 != null || l2 != null || carry != 0) {
            int sum = ((l2 == null) ? 0 : l2.val) + ((l1 == null) ? 0 : l1.val) + carry;
            ListNode node = new ListNode(sum % 10);
            carry = sum / 10;
            cur.next = node;
            cur = node;

            l1 = (l1 == null) ? l1 : l1.next;
            l2 = (l2 == null) ? l2 : l2.next;
        }
        return dummy.next;
    }

    /*
    * 1560 / 1562 test cases passed.
    * Input:
    * [2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,9]
    * [5,6,4,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,2,4,3,9,9,9,9]
    * 溢出
    * */
//    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
//        long num1 = 0;
//        int pos = 0;
//        while (l1 != null) {
//            num1 += (long) (l1.val * Math.pow(10, pos++));
//            l1 = l1.next;
//        }
//
//        long num2 = 0;
//        pos = 0;
//        while (l2 != null) {
//            num2 += (long) (l2.val * Math.pow(10, pos++));
//            l2 = l2.next;
//        }
//
//        long sum = num1 + num2;
//        ListNode dummy = new ListNode(0);
//        if (sum == 0) {
//            return dummy;
//        }
//
//        ListNode cur = dummy;
//        while (sum != 0) {
//            ListNode node = new ListNode((int) (sum % 10));
//            cur.next = node;
//            cur = node;
//            sum /= 10;
//        }
//        cur.next = null;
//        return dummy.next;
//    }

    public static void main(String[] args) {
        LinkedListCreator creator = new LinkedListCreator();
        Add_Two_Numbers add_two_numbers = new Add_Two_Numbers();

//        ListNode l1 = creator.createLinkedList(Arrays.asList(1, 2, 3));
//        ListNode l2 = creator.createLinkedList(Arrays.asList(1));

        // 溢出的情况,将 int 换为 long
//        ListNode l1 = creator.createLinkedList(Arrays.asList(9));
//        ListNode l2 = creator.createLinkedList(Arrays.asList(1, 9, 9, 9, 9, 9, 9, 9, 9, 9));

        ListNode l1 = creator.createLinkedList(Arrays.asList(3, 9, 9, 9, 9, 9, 9, 9, 9, 9));
        ListNode l2 = creator.createLinkedList(Arrays.asList(7));

        ListNode.printLinkedList(add_two_numbers.addTwoNumbers(l1, l2));
    }

}

445. Add Two Numbers II

You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

You may assume the two numbers do not contain any leading zero, except the number 0 itself.

Follow up:
What if you cannot modify the input lists? In other words, reversing the lists is not allowed.
Input: (7 -> 2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 8 -> 0 -> 7
package com.leetcode.linked_list;

import java.util.Arrays;
import java.util.Stack;

public class Add_Two_Numbers_II {
    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
        Stack<Integer> stack_1 = new Stack<>();
        Stack<Integer> stack_2 = new Stack<>();
        while (l1 != null) {
            stack_1.push(l1.val);
            l1 = l1.next;
        }
        while (l2 != null) {
            stack_2.push(l2.val);
            l2 = l2.next;
        }
        ListNode cur = null;
        int carry = 0;
        while (!stack_1.isEmpty() || !stack_2.isEmpty() || carry != 0) {
            int sum = (stack_1.isEmpty() ? 0 : stack_1.pop()) + (stack_2.isEmpty() ? 0 : stack_2.pop()) + carry;
            ListNode node = new ListNode(sum % 10);
            carry = sum / 10;
            node.next = cur;
            cur = node;
        }
        return cur;
    }

    public static void main(String[] args) {
        LinkedListCreator creator = new LinkedListCreator();
        Add_Two_Numbers_II add_two_numbers = new Add_Two_Numbers_II();

//        ListNode l1 = creator.createLinkedList(Arrays.asList(1, 2, 3));
//        ListNode l2 = creator.createLinkedList(Arrays.asList(1));

//        ListNode l1 = creator.createLinkedList(Arrays.asList(1, 2, 3));
//        ListNode l2 = creator.createLinkedList(Arrays.asList(1, 2, 3, 2, 1, 3, 1, 1));

        ListNode l1 = creator.createLinkedList(Arrays.asList(5));
        ListNode l2 = creator.createLinkedList(Arrays.asList(5));

        ListNode.printLinkedList(add_two_numbers.addTwoNumbers(l1, l2));

    }
}

203. Remove Linked List Elements

Remove all elements from a linked list of integers that have value val.

Example
Given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6
Return: 1 --> 2 --> 3 --> 4 --> 5
package com.leetcode.linked_list;

// 203. Remove Linked List Elements

import java.util.Arrays;

public class Remove_Linked_List_Elements {
    public ListNode removeElements(ListNode head, int val) {
        ListNode dummy = new ListNode(0);
        dummy.next = head;
        ListNode pre = dummy;
        ListNode cur = head;
        while (cur != null) {
            if (cur.val == val) {
                pre.next = cur.next;
            } else {
                pre = cur;
            }
            cur = cur.next;
        }
        return dummy.next;
    }

    public static void main(String[] args) {
        LinkedListCreator creator = new LinkedListCreator();
        Remove_Linked_List_Elements remove = new Remove_Linked_List_Elements();

//        ListNode head = creator.createLinkedList(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 7, 5, 4, 3));
        ListNode head = creator.createLinkedList(Arrays.asList(1, 2, 1));

        ListNode.printLinkedList(head);
        ListNode.printLinkedList(remove.removeElements(head, 1));
    }
}

82. Remove Duplicates from Sorted List II

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.

For example,
Given 1->2->3->3->4->4->5, return 1->2->5.
Given 1->1->1->2->3, return 2->3.

package com.leetcode.linked_list;

import java.util.Arrays;

public class Remove_Duplicates_from_Sorted_List_II {
    public ListNode deleteDuplicates(ListNode head) {
        if (head == null || head.next == null)
            return head;
        ListNode dummy = new ListNode(0);
        dummy.next = head;
        ListNode pre = dummy;
        ListNode cur = head;

        while (cur != null) {
            while (cur.next != null && cur.val == cur.next.val) {
                cur = cur.next;
            }
            if (pre.next == cur) {
                pre = pre.next;
            } else {
                pre.next = cur.next;
            }
            cur = cur.next;
        }
        return dummy.next;
    }

    public static void main(String[] args) {
        LinkedListCreator creator = new LinkedListCreator();
        Remove_Duplicates_from_Sorted_List_II remove = new Remove_Duplicates_from_Sorted_List_II();

//        ListNode head = creator.createLinkedList(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 7, 5, 4, 3));
        ListNode head = creator.createLinkedList(Arrays.asList(1, 1));
        ListNode.printLinkedList(remove.deleteDuplicates(head));

    }
}

21. Merge Two Sorted Lists

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.

package com.leetcode.linked_list;

public class Merge_Two_Sorted_Lists {
    public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
        ListNode dummy = new ListNode(0);
        ListNode cur = dummy;
        while (l1 != null && l2 != null) {
            if (l1.val > l2.val) {
                cur.next = l2;
                l2 = l2.next;
            } else {
                cur.next = l1;
                l1 = l1.next;
            }
            cur = cur.next;
        }
        cur.next = (l2 == null) ? l1 : l2;

        return dummy.next;
    }
}

24. Swap Nodes in Pairs

Given a linked list, swap every two adjacent nodes and return its head.

For example,
Given 1->2->3->4, you should return the list as 2->1->4->3.

Your algorithm should use only constant space. You may not modify the values in the list, only nodes itself can be changed.
package com.leetcode.linked_list;

import java.util.Arrays;

public class Swap_Nodes_in_Pairs {
    public ListNode swapPairs(ListNode head) {
        if (head == null || head.next == null)
            return head;
        ListNode dummy = new ListNode(0);
        dummy.next = head;
        ListNode pre = dummy;
        ListNode cur = head;
        ListNode beh = head.next;
        while (beh != null) {
            cur.next = beh.next;
            beh.next = pre.next;
            pre.next = beh;

            pre = cur;
            cur = cur.next;
            if (cur == null)
                break;

            beh = cur.next;
        }
        return dummy.next;
    }

    public static void main(String[] args){
        LinkedListCreator creator = new LinkedListCreator();
        Swap_Nodes_in_Pairs swap = new Swap_Nodes_in_Pairs();

//        ListNode head = creator.createLinkedList(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 7, 5, 4, 3));
        ListNode head = creator.createLinkedList(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 7, 5, 4));

        ListNode.printLinkedList(head);
//        ListNode head = creator.createLinkedList(Arrays.asList(1, 2));
        ListNode.printLinkedList(swap.swapPairs(head));
    }
}

本地IDE调试LeetCode中链表相关问题 当我们想在本地的IDE调试LeetCode代码时,直接复制代码来调试肯定会出问题,链表相关的问题在LeetCode上内部封装了其节点类,所以我们在本地调试的时候,需要自己添加节点类才能正常调试。 首先看LeetCode上关于链表的题目是如何给的: /** * Definition for singly-linked list. * public class ListNode { * ... 阅读详情

相关推荐

编程练习题集——leetcode

一、数组 1.1、简单 第1题 可被 5 整除的二进制前缀 给定由若干 0 和 1 组成的数组 A。我们定义 N_i:从 A[0] 到 A[i] 的第 i 个子数组被解释为一个二进制数(从最高有效位到最低有效位)。 返回布尔值列表 answer,只有当 N_i 可以被 5 整除时,答案 answer[i] 为 true,否则为 false。 示例1: 输入:[0,1,1] 输出:[true,false,false] 解释: 输入数字为 0, 01, 011;也就是十进制中的 0, 1, 3 。只有第一个数可

weixin_45135434的博客 1150

linux 内核链表练习

linux 内核链表使用案例: 链表源码:test_list.c /********************************************** * Author: lewiyon@hotmail.com * File name: test_list.c * Description: test the macroes in the core.h...

weixin_30363981的博客 126

从零到一:DETR模型在自定义数据集上的实战部署与调优

本文详细介绍了DETR模型在自定义数据集上的实战部署与调优过程,包括环境准备、数据转换、模型配置、训练技巧及问题排查。通过具体代码示例和实用建议,帮助开发者高效完成从零到一的DETR模型部署,特别适合目标检测领域的实践应用。

weixin_42524100的博客 469

LeetCode刷题顺序

简介 是不是有许多小伙伴在刷力扣的时候感觉无从下手?从头按顺序开始刷的童鞋们可能会比较有感触,为什么才第四题就感觉很难了?没关系,本文将对力扣的 1-700 题中不需要会员的数据结构与算法题目(数据库与 shell 除外)进行分类,并推荐一个刷题的顺序。 完全零基础可以刷题吗? 不能,至少要基本掌握一门计算机语言的语法。但现在在网上随便搜一下就能搜到许多关于计算机语言的教程。当然,最好还是上一下正规的课程。 刷题顺序很重要吗? 重要。按照题目类别结构化地刷题的速度不仅更快,而且可以在刷完一类题之后进行总

qq_42548880的博客 8924

硅传CC1310二次开发必备:手把手教你用JTAG解锁被锁定的Flash存储器

本文针对硅传CC1310模块二次开发中常见的Flash锁定问题,提供了从原理剖析到实战操作的完整解决方案。详细介绍了如何使用Uniflash和Flash Programmer 2等工具进行Flash解锁和擦除,并强调了硬件连接稳定性与供电质量的关键作用,帮助开发者彻底解决烧录障碍,为后续应用开发铺平道路。

weixin_29189373的博客 260

Android13配置selinux让system应用可读sys,proc,SN号

Android13预置的system应用,需要读/sys, /proc目录,读(SN)serial number号, 需要修改selinux配置,否则会报avc错.其修改方法会比Android11复杂一些.。

zmlovelx(帅得不敢出门 程序员群31843264) 2668

LeetCode之86. Partition List

Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox. You should preserve the original relative order of the nodes in each of t...

iNiBuBian的博客 278

MSP430项目设计:2020年TI杯大学生电子设计竞赛 坡道行驶电动小车(C题)循迹小车(分享项目展示视频与源码)

文章目录题目要求一、硬件设计二、理论分析与计算三、电路与程序设计四、测试方案与测试结果五、项目展示 哔哩哔哩项目展示视频:https://www.bilibili.com/video/BV1oz4y1d7mH/ 百度网盘资料链接:https://pan.baidu.com/s/1PC-lkSORH_XCgIG-u3HCog 提取码:c7zz 取走记得点赞啊! 题目要求 1.任务 利用TI的MSP430/MSP432平台,设计制作一个四轮电动小车。要求小车能沿着指定路线在坡道上自动循迹骑线行驶。小车必须独立

mbs706的博客 4万+

编程题按类型整理记录

动态规划(Dynamic programming: DP) 二分查找 153.寻找旋转排序数组中的最小值 154.寻找旋转排序数组中的最小值 II -----持续更新------

weixin_44623662的博客 405

5、OpenClaw(龙虾助手)飞书机器人完整对接指南(2026最新版)

OpenClaw v2026.2.2+ 版本,防火墙内也能正常工作,是目前最稳定、最简单的企业内部AI助手部署方案。

欢迎光临~知1而N的博客 472

多模态变体—ALIGN:高效的图像-文本学习

ALIGN 论文介绍了该模型的关键技术。无人工标注数据:使用互联网数据进行训练,不依赖人工清洗的数据集。高效的对比学习策略:采用大规模图像-文本配对数据,通过对比学习优化嵌入空间。支持零样本(zero-shot)学习:可以在没有专门训练的情况下执行多种任务,如分类、检索等。可扩展性强:ALIGN 采用高效的 CNN 或 Transformer 作为编码器,适用于大规模计算。

Azperk的博客 1230

leetcode链表面试题目集锦

本文系转载,出处信息 作者:Mr希灵 链接:https://www.jianshu.com/p/f0c3235369ac 來源:简书 1.链表 链表是最基本的数据结构,面试官也常常用链表来考察面试者的基本能力,而且链表相关的操作相对而言比较简单,也适合考察写代码的能力。链表的操作也离不开指针,指针又很容易导致出错。综合多方面的原因,链表题目在面试中占据着很重要的地位。 1.1定义 链...

xiangxianghehe的博客 1万+

基于matlab的主成分分析的人脸二维码识别系统

人脸识别因其在系统安全验证、信用验证、刑侦跟踪、身份管理、视频会议、人机交互、智能家居等方面的巨大应用前景,成为当前模式识别和人工智能领域越来越热门的一个研究方向。随着安全入口控制和二维码智能扫描应用需求的快速增长,基于二维码识别的生物人脸统计识别技术也引起了人们的重视。本案例将详细讲解基于主成分分析的人脸特征提取的原理与方法,并将其与 QR 二维码的编解码进行结合,将 MATLAB 作为工具平台,调用 QR 二维码编解码应用程序,进而实现一个人脸二维码自动识别的系统原型。

在职AI算法工程师,擅长计算机视觉,YOLO目标检测、分割等,擅长web、pyqt界面可视化,好内容持续更新中,来这里跟大家一起学习,共同进步 988

链表【各种题型+对应LeetCode习题练习】

本文详解链表核心知识:对比数组差异,解析单 / 双 / 循环链表结构。通过 LeetCode 经典例题,拆解遍历、插入删除、反转、合并等操作,详解虚拟头节点、快慢指针等技巧。

2301_79609207的博客 1743

MySQL操作之用户管理权限管理:(DC)(五)

一、简介 二、用户管理 2.1 User表 2.2 创建普通用户 2.3 删除普通用户 2.4 修改用户密码 2.5 解决root用户密码丢失 三、权限管理 3.1 MySQL的权限 3.2 授予权限 3.3 查看权限 3.4 收回权限

lydms的博客 4513

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

【LeetCode力扣】86. 分隔链表

86. 分隔链表 - 力扣(LeetCode)考虑通过「新建两个链表」实现原链表分割,算法流程为:新建两个链表small和BigEqu,分别用于链接小于标志数 x 的结点和大于等于标志数 x 的结点。遍历链表head并依次比较各节点值 head->val 和 x 的大小,若head->val < x ,则将head指向的该结点添加到链表 small 最后面。若head->val >=x,则将head指向的该结点添加到链表BigEqu最后面。遍历完成后,拼接small和Big

Hacynn的博客 1724

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

力扣关于链表有关的练习题

力扣链表题目

m0_61608447的博客 1032

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

链表相关知识及练习

在链表的尾部插入节点是另一种常见的操作,它涉及遍历整个链表直到最后一个节点,然后更新最后一个节点的指针,使其指向新插入的节点。在链表的头部插入节点是一种常见的操作,它通常涉及更新头节点的指针,使其指向新插入的节点。新节点的指针则指向原来的头节点。在链表的第n个节点前插入一个新节点是一个常见的操作,它涉及找到第n个节点,然后在这个节点前插入新节点。删除链表中的第n个节点是一个常见的操作,它涉及找到第n-1个节点,然后调整其。获取链表中第n个节点的值通常需要从头节点开始遍历链表,直到到达第n个节点。

2301_81321130的博客 973

学习笔记—数据结构—单链表(练习题)

对于咱们对编程有兴趣或者成为陌生手段来说,刷题一般用牛客网和力扣牛客网 - 找工作神器|笔试题库|面试经验|实习招聘内推,求职就业一站解决_牛客网力扣 (LeetCode) 全球极客挚爱的技术成长平台。

2401_83231468的博客 1533

链表经典练习题

本篇文章到这里就结束了,如果有不理解的题目,可私信或在评论区留下问题,记得一定要练习,这是非常重要的。再强调:大部分题目解法只为了抛砖引玉。希望对大家有所启发。完!

2302_81016149的博客 1472

力扣(leetcode)题目总结——链表篇

本系列文章初衷是为了按类别整理出力扣(leetcode)最经典题目,一共100多道题,每道题都给出了非常详细的解题思路、算法步骤、代码实现。因为力扣题目顺序是随机的,并没有按照算法分类,导致同一类型的算法强化训练不够。所以本系列文章就是来帮你完成算法分类,针对每种算法做强化训练,保证让你以后遇到题目直接秒杀。本篇文章主要是针对链表相关的算法题,一次性帮你搞定所有链表题!

weixin_46571171的博客 2801

链表相关力扣练习题

链表相关力扣习题

qq_39172845的博客 488

链表算法练习

创建新链表,并且建立头尾指针,将原链表不等于val的值尾插到新链表中。注意:在写代码中,最后一定要判断nwetile是否等于零,从而使下一个指针指向NULL,否则就会出现下面的错误,导致最后面与val相同的值没有删除。

L73S37的博客 927

链表的相关习题

给你一个链表,删除链表的倒数第n个结点,并且返回链表的头结点。[1,2,3,5][][1]本题利用快慢指针,首先利用循环使两个指针之间相差n个结点,然后再利用循环使双指针同时向后移动,直到快指针移动到链表尾部,这时便可利用慢指针删除倒数第n个结点。

2401_88110477的博客 709

掌握这15种模式后,力扣(LeetCode)不再难

在掌握这15种模式之前,力扣(LeetCode)对我来说一直很难。

硅基创想家的博客 4373

链表算法及习题

㈠线性表:线性表的链式存储结构是用一组任意的存储单元来存放线性表的数据元素,这组存储单元可以是连续的,也可以是不连续的。对每个数据元素ai,除了存储其本身的信息之外,还需存储一个指示其直接后继存放位置的指针。这两部分信息组成数据元素ai的存储映像,称为结点(node)。它包括两个域:其中存储数据元素信息的域称为数据域;存储直接后继存放位置的域称为指针域。如果每个结点只设置一个指向其后继结点的指针成员,这样的链表称为线性单向链接表,简称单链表。

2401_86148944的博客 1153
上一篇: 递归控制
下一篇: 常用的排序算法性能分析(1)—— 选择排序、插入排序、希尔排序
HeatDeath
博客等级 码龄11年 906粉丝 924原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值