代码随想录五刷day12

Langchain4j 文档处理实战:从加载到分割的完整流程解析 本文详细解析了使用Langchain4j进行文档处理的完整流程,涵盖从文档加载、解析到分割的核心步骤。通过实战代码示例,重点介绍了如何利用文档分割器将大文档切割为适合大语言模型处理的片段,并提供了参数调优与避坑指南,帮助Java开发者高效构建AI应用的数据处理基础。 阅读详情

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


前言


一、力扣98. 所有可达路径

import java.util.*;
public class Main{
    public static List<List<Integer>> res = new ArrayList<>();
    public static List<Integer> path = new ArrayList<>();
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int[][] graph = new int[n+1][n+1];
        for(int i = 1; i <= m; i ++){
            int from = in.nextInt();
            int to = in.nextInt();
            graph[from][to] = 1;
        }
        path.add(1);
        for(int i = 1; i <= n; i ++){
            if(graph[1][i] != 0){
                path.add(i);
                fun(graph, i, n);
                path.remove(path.size()-1);
            }
        }
        if(res.size() == 0){
            System.out.println(-1);
            return;
        }
        for(List<Integer> p : res){
            for(int i = 0; i < p.size(); i ++){
                System.out.print(p.get(i));
                if(i < p.size()-1){
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
    public static void fun(int[][] graph, int cur, int n){
        if(cur == n){
            res.add(new ArrayList<>(path));
            return;
        }
        for(int i = 1; i <= n; i ++){
            if(graph[cur][i] != 0){
                path.add(i);
                fun(graph,i,n);;
                path.remove(path.size()-1);
            }
        }
    }
}

邻接表

import java.util.*;
public class Main{
    public static List<List<Integer>> res = new ArrayList<>();
    public static List<Integer> path = new ArrayList<>();
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        List<List<Integer>> graph = new ArrayList<>();
        for(int i = 0; i <= n; i ++){
            graph.add(new ArrayList<Integer>());
        }
        for(int i = 1; i <= m; i ++){
            int from = in.nextInt();
            int to = in.nextInt();
            graph.get(from).add(to);
        }
        path.add(1);
        fun(graph, 1, n);
        if(res.size() == 0){
            System.out.println(-1);
            return;
        }
        for(List<Integer> p : res){
            for(int i = 0; i < p.size(); i ++){
                System.out.print(p.get(i));
                if(i < p.size()-1){
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
    public static void fun(List<List<Integer>> graph, int cur, int n){
        if(cur == n){
            res.add(new ArrayList<>(path));
            return;
        }
        for(Integer t : graph.get(cur)){
            path.add(t);
            fun(graph,t,n);;
            path.remove(path.size()-1);
        }
    }
}

二、力扣797. 所有可能的路径

class Solution {
    List<List<Integer>> res = new ArrayList<>();
    List<Integer> path = new ArrayList<>();
    public List<List<Integer>> allPathsSourceTarget(int[][] graph) {
        int n = graph.length;
        path.add(0);
        dfs(graph, 0, n);
        return res;
    }
    public void dfs(int[][] graph, int cur, int n){
        if(cur == n-1){
            res.add(new ArrayList<>(path));
            return;
        }
        for(int i = 0; i < graph[cur].length; i ++){
            path.add(graph[cur][i]);
            dfs(graph, graph[cur][i], n);
            path.remove(path.size()-1);
        }
    }
}

三、力扣99. 岛屿数量

在这里插入代码片import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int[][] graph = new int[n][m];
        for(int i = 0; i < n; i ++){
            for(int j = 0; j < m; j ++){
                graph[i][j] = in.nextInt();
            }
        }
        Deque<int[]> deq = new LinkedList<>();
        int[][] arr = new int[][]{
            {-1,0}, {1,0}, {0,-1}, {0,1}
        };
        int res = 0;
        boolean[][] flag = new boolean[n][m];
        for(int i = 0; i < n; i ++){
            for(int j = 0; j < m; j ++){
                if(!flag[i][j] && graph[i][j] == 1){
                    deq.offerLast(new int[]{i,j});
                    while(!deq.isEmpty()){
                        int[] cur = deq.pollLast();
                        for(int k = 0; k < 4; k ++){
                            int nextX = cur[0] + arr[k][0];
                            int nextY = cur[1] + arr[k][1];
                            if(nextX < 0 || nextX >= n || nextY < 0 || nextY >= m){
                                continue;
                            }
                            if( flag[nextX][nextY] || graph[nextX][nextY] == 0){
                                continue;
                            }
                            deq.offerLast(new int[]{nextX, nextY});
                            flag[nextX][nextY] = true;
                        }
                    }
                    res ++;
                }
            }
        }
        System.out.println(res);
    }
}

四、力扣99. 岛屿数量

import java.util.*;
public class Main{
    private static int[][] arr = new int[][]{
            {-1,0}, {1,0}, {0,-1}, {0,1}
        };
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int[][] graph = new int[n][m];
        for(int i = 0; i < n; i ++){
            for(int j = 0; j < m; j ++){
                graph[i][j] = in.nextInt();
            }
        }
        int  res = 0;
        
        boolean[][] flag = new boolean[n][m];
        for(int i = 0; i < n; i ++){
            for(int j = 0; j < m; j ++){
                if(!flag[i][j] && graph[i][j] == 1){
                    res ++;
                    flag[i][j] = true;
                    dfs(flag, graph, i, j, n,m);
                }
            }
        }
        System.out.println(res);
    }
    public static void dfs(boolean[][] flag, int[][] graph, int curX, int curY, int n,int m){
        for(int k = 0; k < 4; k ++){
            int nextX = curX + arr[k][0];
            int nextY = curY + arr[k][1];
            if(nextX < 0 || nextX >= n || nextY < 0 || nextY >= m){
                continue;
            }
            if( flag[nextX][nextY] || graph[nextX][nextY] == 0){
                continue;
            }
            flag[nextX][nextY] = true;
            dfs(flag, graph, nextX, nextY, n, m);
            
        }
    }
}

五、力扣100. 岛屿的最大面积

import java.util.*;

public class Main {
    private static int temp = 0;
    private static int[][] arr = new int[][] {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int m = in.nextInt();
        int n = in.nextInt();
        int[][] graph = new int[m][n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                graph[i][j] = in.nextInt();
            }
        }
        boolean[][] flag = new boolean[m][n];
        int res = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (!flag[i][j] && graph[i][j] == 1) {
                    flag[i][j] = true;
                    temp = 0;
                    bfs(graph, flag, i, j);
                    res = Math.max(res, temp);
                }
            }
        }
        System.out.println(res);
    }

    private static void bfs(int[][] graph, boolean[][] flag, int curX, int curY) {
        Deque<int[]> deq = new LinkedList<>();
        deq.offerLast(new int[] {curX, curY});
        temp++;
        while (!deq.isEmpty()) {
            int[] cur = deq.pollFirst();
            for (int i = 0; i < 4; i++) {
                int nextX = cur[0] + arr[i][0];
                int nextY = cur[1] + arr[i][1];
                if (nextX < 0 || nextX >= graph.length || nextY < 0 || nextY >= graph[0].length) {
                    continue;
                }
                if (flag[nextX][nextY] || graph[nextX][nextY] == 0) {
                    continue;
                }
                flag[nextX][nextY] = true;
                temp++;
                deq.offerLast(new int[] {nextX, nextY});
            }
        }
    }
}

六、力扣101. 孤岛的总面积

import java.util.*;
public class Main{
    public static int[][] arr = new int[][]{
        {-1,0}, {1,0}, {0,-1}, {0,1}
    };
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int m = in.nextInt();
        int n = in.nextInt();
        int[][] graph = new int[m][n];
        for(int i = 0; i < m; i ++){
            for(int j = 0; j < n; j ++){
                graph[i][j] = in.nextInt();
            }
        }
        boolean[][] flag = new boolean[m][n];
        int res = 0;
        for(int i = 0; i < m; i ++){
            if(graph[i][0] == 1)
            dfs(graph, flag, i, 0);
            if(graph[i][n-1] == 1)
            dfs(graph, flag, i, n-1);
        }
        for(int i = 0; i < n; i ++){
            if(graph[0][i] == 1)
            dfs(graph, flag, 0, i);
            if(graph[m-1][i] == 1)
            dfs(graph, flag, m-1, i);
        }
        for(int i = 0; i < m; i ++){
            for(int j = 0; j < n; j ++){
                if(graph[i][j] == 1){
                    res ++;
                }
            }
        }
        System.out.println(res);
    }
    public static void dfs(int[][] graph, boolean[][] flag, int curx, int cury){
        flag[curx][cury] = true;
        graph[curx][cury] = 0;
        for(int i = 0; i < 4; i ++){
            int nextx = curx + arr[i][0];
            int nexty = cury + arr[i][1];
            if(nextx < 0 || nextx >= graph.length || nexty < 0 || nexty >= graph[0].length){
                continue;
            }
            if(flag[nextx][nexty] || graph[nextx][nexty] == 0){
                continue;
            }
            flag[nextx][nexty] = true;
            dfs(graph, flag, nextx, nexty);
        }
    }
}

七、力扣102. 沉没孤岛

import java.util.*;
public class Main{
    public static int[][] arr = new int[][]{
        {-1,0}, {1,0}, {0,-1}, {0,1}
    };
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int m = in.nextInt();
        int n = in.nextInt();
        int[][] griph = new int[m][n];
        boolean[][] flag = new boolean[m][n];
        for(int i = 0; i < m; i ++){
            for(int j = 0; j < n; j ++){
                griph[i][j] = in.nextInt();
            }
        }
        for(int i = 0; i < m; i ++){
            if(!flag[i][0] && griph[i][0] == 1){
                dfs(griph, flag, i, 0);
            }
            if(!flag[i][n-1] && griph[i][n-1] == 1){
                dfs(griph, flag, i, n-1);
            }
        }
        for(int i = 0; i < n; i ++){
            if(!flag[0][i] && griph[0][i] == 1){
                dfs(griph, flag, 0, i);
            }
            if(!flag[m-1][i] && griph[m-1][i] == 1){
                dfs(griph, flag, m-1, i);
            }
        }
        for(int i = 0; i < m; i ++){
            for(int j = 0; j < n; j ++){
                if(!flag[i][j] && griph[i][j] == 1){
                    System.out.print(0);
                }else{
                    System.out.print(griph[i][j]);
                }
                if(j <= n-1){
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
        
    }
    public static void dfs(int[][] griph, boolean[][] flag, int curx, int cury){
        flag[curx][cury] = true;
        for(int i = 0; i < 4; i ++){
            int nextx = curx + arr[i][0];
            int nexty = cury + arr[i][1];
            if(nextx < 0 || nextx >= griph.length || nexty < 0 || nexty >= griph[0].length){
                continue;
            }
            if(flag[nextx][nexty] || griph[nextx][nexty] == 0){
                continue;
            }
            dfs(griph,  flag, nextx, nexty);
        }
    }
}

八、力扣103. 水流问题

import java.util.*;
public class Main{
    public static int[][] arr = new int[][]{
        {-1,0}, {1,0}, {0,-1}, {0,1}
    };
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        int[][] griph = new int[m][n];
        boolean[][] flaga = new boolean[m][n];
        boolean[][] flagb = new boolean[m][n];
        for(int i = 0; i < m; i ++){
            for(int j = 0; j < n; j ++){
                griph[i][j] = sc.nextInt();
            }
        }
        for(int i = 0; i < n; i ++){
            if(!flaga[0][i]){
                bfs(griph, flaga, 0, i);
            }
        }
        for(int i = 0; i < m; i ++){
            if(!flaga[i][0]){
                bfs(griph, flaga, i, 0);
            }
        }
        for(int i = 0; i < m; i ++){
            if(!flagb[i][n-1]){
                bfs(griph, flagb, i, n-1);
            }
        }
        for(int i = 0; i < n; i ++){
            if(!flagb[m-1][i]){
                bfs(griph, flagb, m-1, i);
            }
        }
        for(int i = 0; i < m; i ++){
            for(int j = 0; j < n; j ++){
                if(flaga[i][j] && flagb[i][j]){
                    System.out.println(i + " " + j);
                }
            }
        }
    }
    public static void bfs(int[][] griph, boolean[][] flag, int x, int y){
        flag[x][y] = true;
        Deque<int[]> deq = new LinkedList<>();
        deq.offerLast(new int[]{x,y});
        while(!deq.isEmpty()){
            int[] cur = deq.pollFirst();
            for(int i = 0; i < 4; i ++){
                int nextx = cur[0] + arr[i][0];
                int nexty = cur[1] + arr[i][1];
                if(nextx < 0 || nextx >= griph.length || nexty < 0 || nexty >= griph[0].length){
                    continue;
                }
                if(flag[nextx][nexty] || griph[x][y] > griph[nextx][nexty]){
                    continue;
                }
                flag[nextx][nexty] = true;
                bfs(griph, flag, nextx, nexty);
            }
        }
    }
}

九、力扣104. 建造最大岛屿

import java.util.*;
public class Main{
    public static int[][] arr = new int[][]{
        {-1,0}, {1,0}, {0,-1}, {0,1}
    };
    public static Map<Integer,Integer> map = new HashMap<>();
    public static int t = 2;
    public static int sum = 0;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        int[][] griph = new int[m][n];
        boolean[][] flag = new boolean[m][n];
        for(int i = 0; i < m; i ++){
            for(int j = 0; j < n; j ++){
                griph[i][j] = sc.nextInt();
            }
        }
        int res = 0;
        for(int i = 0; i < m; i ++){
            for(int j = 0; j < n; j ++){
                if(!flag[i][j] && griph[i][j] == 1){
                    dfs(flag, griph, i, j);
                    map.put(t, sum);
                    res = Math.max(res, sum);
                    t ++;
                    sum = 0;
                }
            }
        }
        for(int i = 0; i < m; i ++){
            for(int j = 0; j < n; j ++){
                if(griph[i][j] == 0){
                    int count = 0;
                    Set<Integer> set = new HashSet<>();
                    for(int k = 0; k < 4; k ++){
                        int x = i + arr[k][0];
                        int y = j + arr[k][1];
                        if(x < 0 || x >= m || y < 0 || y >= n){
                            continue;
                        }
                        if(griph[x][y] > 1){
                            set.add(griph[x][y]);
                        }
                    }
                    for(int dd : set){
                        count += map.get(dd);
                    }
                    res = Math.max(res, count+1);
                }
            }
        }
        System.out.println(res);
    }
    public static void dfs(boolean[][] flag, int[][] griph, int x, int y){
        griph[x][y] = t;
        sum ++;
        flag[x][y] = true;

        for(int i = 0; i < 4; i ++){
            int curx = x + arr[i][0];
            int cury = y + arr[i][1];
            if(curx < 0 || curx >= griph.length || cury < 0 || cury >= griph[0].length){
                continue;
            }
            if(flag[curx][cury] || griph[curx][cury] == 0 || griph[curx][cury] > 1){
                continue;
            }
            dfs(flag, griph, curx, cury);
        }
    }
}


十、力扣106. 岛屿的周长

import java.util.*;
public class Main{
    public static int[][] arr = new int[][]{
        {-1,0}, {1,0}, {0,-1}, {0,1}
    };
    public static int count = 0;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        int[][] griph = new int[m][n];
        boolean[][] flag = new boolean[m][n];
        for(int i = 0; i < m; i ++){
            for(int j = 0; j < n; j ++){
                griph[i][j] = sc.nextInt();
            }
        }
        for(int i = 0; i < m; i ++){
            for(int j = 0; j < n; j ++){
                if(!flag[i][j] && griph[i][j] == 1){
                    dfs(flag, griph, i, j);
                }
            }
        }
        System.out.println(count);
    }
    public static void dfs(boolean[][] flag, int[][] griph, int x, int y){
        flag[x][y] = true;
        for(int i = 0; i < 4; i ++){
            int curx = x + arr[i][0];
            int cury = y + arr[i][1];
            if(curx < 0 || curx >= griph.length || cury < 0 || cury >= griph[0].length){
                count ++;
                continue;
            }
            if(flag[curx][cury]){
                continue;
            }
            if(griph[curx][cury] == 0){
                count ++;
                continue;
            }
            dfs(flag, griph, curx, cury);
        }
    }
}

十一、力扣110. 字符串接龙

在这里插入代码片

十二、力扣3. 无重复字符的最长子串

class Solution {
    public int lengthOfLongestSubstring(String s) {
        int res = 0;
        if(s.length() == 0 || s.length() == 1){
            return s.length();
        }
        char[] ch = s.toCharArray();
        int left = -1, right = 0;
        Map<Character,Integer> map = new HashMap<>();
        while(left < right && right < ch.length){
            map.put(ch[right], map.getOrDefault(ch[right],0) + 1);
            while(map.get(ch[right]) > 1){
                left ++;
                map.put(ch[left], map.get(ch[left]) - 1);
            }
            res = Math.max(right-left, res);
            right ++;
        }
        return res;
    }
}

十三、力扣146. LRU 缓存

class LRUCache {
    public Map<Integer,DNode> map = new HashMap<>();
    public int count = 0;
    public int capacity;
    public DNode head;
    public DNode tail;

    public LRUCache(int capacity) {
        this.capacity = capacity;
        this.head = new DNode(-1,-1);
        this.tail = new DNode(-1,-1);
        this.head.next = this.tail;
        this.tail.prev = this.head;
    }
    
    public int get(int key) {
        if(map.containsKey(key)){
            DNode cur = remove(key);
            cur = addTail(cur);
            return cur.value;
        }else{
            return -1;
        }
    }
    
    public void put(int key, int value) {
        if(map.containsKey(key)){
            DNode cur = map.get(key);
            cur = remove(cur.key);
            cur.value = value;
            addTail(cur);
        }else if(count >= capacity){
            DNode d = remove(head.next.key);
            map.remove(d.key);
            DNode cur = new DNode(key, value);
            addTail(cur);
            map.put(key, cur);
        }else{
            count ++;
            DNode cur = new DNode(key, value);
            addTail(cur);
            map.put(key, cur);
        }
    }

    public DNode addTail(DNode node){
        node.prev = this.tail.prev;
        node.next = this.tail;
        this.tail.prev.next = node;
        this.tail.prev = node;
        return node;
    }

    public DNode remove(int key){
        DNode cur = map.get(key);
        cur.prev.next = cur.next;
        cur.next.prev = cur.prev;
        cur.prev = null;
        cur.next = null;
        return cur;
    }
}
class DNode{
    public int key;
    public int value;
    public DNode prev;
    public DNode next;
    public DNode(int key, int value){
        this.key = key;
        this.value = value;
    }
    public DNode(){

    }
    
}

/**
 * Your LRUCache object will be instantiated and called as such:
 * LRUCache obj = new LRUCache(capacity);
 * int param_1 = obj.get(key);
 * obj.put(key,value);
 */

十四、力扣206. 反转链表

/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution {
    public ListNode reverseList(ListNode head) {
        ListNode L = new ListNode(-1,null);
        ListNode pre = head;
        while(pre != null){
            ListNode t = pre;
            pre = pre.next;
            t.next = L.next;
            L.next = t;
        }
        return L.next;
    }
}

十五、力扣15. 三数之和

class Solution {
    public List<List<Integer>> threeSum(int[] nums) {
        List<List<Integer>> res = new ArrayList<>();
        Arrays.sort(nums);
        for(int i = 0; i < nums.length-2; i ++){
            if(i > 0 && nums[i] == nums[i-1]){
                continue;
            }
            for(int j = i+1, k = nums.length-1; j < k; ){
                
                
                int sum = nums[i] + nums[j] + nums[k];
                if(sum == 0){
                    List<Integer> list = new ArrayList<>();
                    list.add(nums[i]);
                    list.add(nums[j]);
                    list.add(nums[k]);
                    res.add(list);
                    do{
                        j ++;
                    }while(j > i+1 && nums[j] == nums[j-1] && j < k);
                    do{
                        k --;
                    }while(k < nums.length-1 && nums[k] == nums[k+1] && j < k);
                }else if(sum < 0){
                    do{
                        j ++;
                    }while(j > i+1 && nums[j] == nums[j-1] && j < k);
                }else{
                    do{
                        k --;
                    }while(k < nums.length-1 && nums[k] == nums[k+1] && j < k);
                }
            }
        }
        return res;
    }
}

十六、力扣53. 最大子数组和

class Solution {
    public int maxSubArray(int[] nums) {
        int res = Integer.MIN_VALUE, count = 0;
        for(int i = 0; i < nums.length; i ++){
            if(count >= 0){
                count += nums[i];
            }else{
                count = nums[i];
            }
            res = Math.max(res, count);
        }
        return res;
    }
}

十七、力扣21. 合并两个有序链表

/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution {
    public ListNode mergeTwoLists(ListNode list1, ListNode list2) {
        ListNode p1 = list1, p2 = list2;
        ListNode head = new ListNode();
        ListNode pre = head;
        while(p1 != null && p2 != null){
            if(p1.val < p2.val){
                ListNode t = p1;
                p1 = p1.next;
                pre.next = t;
                pre = pre.next;
            }else{
                ListNode t = p2;
                p2 = p2.next;
                pre.next = t;
                pre = pre.next;
            }
        }
        if(p1 != null){
            pre.next = p1;
        }else{
            pre.next = p2;
        }
        return head.next;
    }
}

十八、力扣5. 最长回文子串

class Solution {
    public String longestPalindrome(String s) {
        String res = "";
        for(int i = 0; i < s.length(); i ++){
            String str1 = fun(s, i, i);
            String str2 = fun(s, i, i + 1);
            res = str1.length() > res.length() ? str1 : res;
            res = str2.length() > res.length() ? str2 : res;
        }
        return res;
    }
    public String fun(String s, int l, int r){
        while(l >= 0 && r < s.length()){
            if(s.charAt(l) == s.charAt(r)){
                l --;
                r ++;
            }else{
                break;
            }
        }
        return s.substring(l+1,r);
    }
}

十九、力扣102. 二叉树的层序遍历

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode() {}
 *     TreeNode(int val) { this.val = val; }
 *     TreeNode(int val, TreeNode left, TreeNode right) {
 *         this.val = val;
 *         this.left = left;
 *         this.right = right;
 *     }
 * }
 */
class Solution {
    public List<List<Integer>> levelOrder(TreeNode root) {
        Deque<TreeNode> deq = new LinkedList<>();
        deq.offerLast(root);
        List<List<Integer>> res = new ArrayList<>();
        if(root == null){
            return res;
        }
        while(!deq.isEmpty()){
            int size = deq.size();
            List<Integer> list = new ArrayList<>();
            for(int i = 0; i < size; i ++){
                TreeNode cur = deq.pollFirst();
                list.add(cur.val);
                if(cur.left != null){
                    deq.offerLast(cur.left);
                }
                if(cur.right != null){
                    deq.offerLast(cur.right);
                }
            }
            res.add(list);
        }
        return res;
    }
}

二十、力扣1. 两数之和

class Solution {
    public int[] twoSum(int[] nums, int target) {
        Map<Integer,Integer> map = new HashMap<>();
        for(int i = 0; i < nums.length; i ++){
            map.put(nums[i], i);
        }
        for(int i = 0; i < nums.length; i ++){
            int cur = target - nums[i];
            if(map.containsKey(cur) && i != map.get(cur)){
                return new int[]{i, map.get(cur)};
            }
        }
        return null;
    }
}

二十一、力扣33. 搜索旋转排序数组

class Solution {
    public int search(int[] nums, int target) {
        int n = nums.length;
        if(n == 0){
            return -1;
        }
        if(n == 1){
            return nums[0] == target ? 0 : -1;
        }
        int l = 0, r = n-1;
        while(l <= r){
            int mid = l + (r-l)/2;
            if(nums[mid] == target){
                return mid;
            }
            if(nums[0] <= nums[mid]){
                if(nums[0] <= target && nums[mid] > target){
                    r = mid - 1;
                }else{
                    l = mid + 1;
                }
            }else{
                if(nums[mid] < target && target <= nums[n-1]){
                    l = mid + 1;
                }else{
                    r = mid - 1;
                }
            }
        }
        return -1;
    }
}

二十二、力扣200. 岛屿数量

class Solution {
    int[][] arr = new int[][]{
        {-1,0}, {1,0}, {0,-1}, {0,1}
    };
    boolean[][] flag;
    public int numIslands(char[][] grid) {
        flag = new boolean[grid.length][grid[0].length];
        int count = 0;
        for(int i = 0; i < grid.length; i ++){
            for(int j = 0; j < grid[0].length; j ++){
                if(!flag[i][j] && grid[i][j] == '1'){
                    count ++;
                    dfs(grid, i, j);
                }
            }
        }
        return count;
    }
    public void dfs(char[][] grid, int x, int y){
        flag[x][y] = true;
        for(int i = 0; i < 4; i ++){
            int curx = x + arr[i][0];
            int cury = y + arr[i][1];
            if(curx < 0 || curx >= grid.length || cury < 0 || cury >= grid[0].length){
                continue;
            }
            if(flag[curx][cury] || grid[curx][cury] == '0'){
                continue;
            }
            dfs(grid, curx, cury);
        }
    }
}

二十三、力扣46. 全排列

class Solution {
    List<List<Integer>> res = new ArrayList<>();
    List<Integer> path = new ArrayList<>();
    boolean[] flag;
    public List<List<Integer>> permute(int[] nums) {
        flag = new boolean[nums.length];
        fun(nums);
        return res;
    }
    public void fun(int[] nums){
        if(path.size() == nums.length){
            res.add(new ArrayList<>(path));
            return ;
        }
        for(int i = 0; i < nums.length; i ++){
            if(!flag[i]){
                path.add(nums[i]);
                flag[i] = true;
                fun(nums);
                path.remove(path.size()-1);
                flag[i] = false;
            }
        }
    }
}

二十四、力扣20. 有效的括号

class Solution {
    public boolean isValid(String s) {
        Deque<Character> deq = new ArrayDeque<>();
        for(char c : s.toCharArray()){
            if(c == '(' || c == '[' || c == '{'){
                deq.offerLast(c);
            }else{
                if(deq.isEmpty()){
                    return false;
                }
                char t = deq.peekLast();
                if(c == ')' && t != '('){
                    return false;
                }
                if(c == ']' && t != '['){
                    return false;
                }
                if(c == '}' && t != '{'){
                    return false;
                }
                deq.pollLast();
            }
        }
        return deq.size() == 0;
    }
}

二十五、力扣121. 买卖股票的最佳时机

class Solution {
    public int maxProfit(int[] prices) {
        int n = prices.length;
        int[][] dp = new int[n][2];
        dp[0][0] = -prices[0];
        for(int i = 1; i < n; i ++){
            dp[i][0] = Math.max(dp[i-1][0], -prices[i]);
            dp[i][1] = Math.max(dp[i-1][1], dp[i-1][0] + prices[i]);
        }
        return dp[n-1][1];
    }
}

二十六、力扣236. 二叉树的最近公共祖先

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode(int x) { val = x; }
 * }
 */
class Solution {
    public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
        if(root == null || root == p || root == q){
            return root;
        }
        TreeNode l = lowestCommonAncestor(root.left, p, q);
        TreeNode r = lowestCommonAncestor(root.right, p, q);
        if(l == null && r == null){
            return null;
        }else if(l != null && r == null){
            return l;
        }else if(l == null && r != null){
            return r;
        }else{
            return root;
        }
    }
}

二十七、力扣141. 环形链表

/**
 * Definition for singly-linked list.
 * class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) {
 *         val = x;
 *         next = null;
 *     }
 * }
 */
public class Solution {
    public boolean hasCycle(ListNode head) {
        if(head == null || head.next == null){
            return false;
        }
        ListNode L = new ListNode(-1, head);
        ListNode s = L.next, f = L.next.next;
        while(s != null && f != null){
            if(s == f){
                return true;
            }
            s = s.next;
            if(f.next == null){
                return false;
            }
            f = f.next.next;
        }
        return false;
    }
}

二十八、力扣300. 最长递增子序列

class Solution {
    public int lengthOfLIS(int[] nums) {
        int n = nums.length;
        int[] dp = new int[n];
        Arrays.fill(dp, 1);
        int res = 1;
        for(int i = 1; i <n; i ++){
            for(int j = 0; j < i; j ++){
                if(nums[i] > nums[j]){
                    dp[i] = Math.max(dp[i], dp[j] + 1);
                }
                res = Math.max(res, dp[i]);
            }
        }
        return res;
    }
}

二十九、力扣23. 合并 K 个升序链表

在这里插入代码片/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution {
    public ListNode mergeKLists(ListNode[] lists) {
        ListNode L = new ListNode(-1,null), r = L;
        PriorityQueue<ListNode> pq = new PriorityQueue<>(
            (a,b) -> {return a.val - b.val;}
        );
        if(lists == null || lists.length == 0){
            return null;
        }
        for(ListNode node : lists){
            while(node != null){
                pq.offer(node);
                node = node.next;
            }
        }
        while(!pq.isEmpty()){
            ListNode cur = pq.poll();
            r.next = cur;
            r = r.next;
        }
        r.next = null;
        return L.next;
    }
}

三十、力扣160. 相交链表

/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) {
 *         val = x;
 *         next = null;
 *     }
 * }
 */
public class Solution {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        int l1 = 0, l2 = 0;
        ListNode p1 = headA, p2 = headB;
        while(p1 != null){
            l1 ++;
            p1 = p1.next;
        }
        while(p2 != null){
            l2 ++;
            p2 = p2.next;
        }
        if(l1 > l2){
            p1 = headA;
            p2 = headB;
            int c = l1 - l2;
            while( c -- > 0){
                p1 = p1.next;
            }
        }else if(l2 > l1){
            p2 = headB;
            p1 = headA;
            int c = l2 - l1;
            while(c -- > 0){
                p2 = p2.next;
            }
        }else{
            p1 = headA;
            p2 = headB;
        }
        while(p1 != null && p2 != null){
            if(p1 == p2){
                return p1;
            }
            p1 = p1.next;
            p2 = p2.next;
        }
        return null;
    }
}

三十一、力扣

ubuntu emto-cpa安装与编译 阅读详情

相关推荐

C/C++关于VScode报错“终端将被任务重用,按任意键关闭”的解决方案

这其实不是一种报错,有这个提示的原因是本地端口是被共享的,所以必须关闭一个进程才能执行另一个,只需要对 tasks.json文件做一些修改即可。 报错时候 此时的tasks.json为: { "version": "2.0.0", "command": "g++", "args": ["-g","${file}","-o","${fileDirname}/${fileBasenameNoExtension}.exe"], // 编译命令参数 "problemMatche

Jerry Man的博客 6435

代码随想录五刷day10

动态规划

ResNet156的博客 1135

微信小程序转化数据API自归因实战:PHP实现与2025升级要点解析

本文详细解析了2025年微信小程序转化数据API自归因的升级要点与PHP实战实现。核心变化包括接口地址更新、固定access_token的获取方式,以及新增timestamp与nonce等安全参数。文章提供了完整的PHP代码示例,帮助开发者高效完成数据上报,优化腾讯广告投放效果。

git9versioner的博客 993

Day12 代码随想录 刷题记录

今日刷题2题,总计用时3h45mins。字符串操作中,对于数组的具体值的移动与定位分析得不是很清楚;对于双指针的使用还不够熟悉。

windyyyyyyyyyyy的博客 1090

【微电网优化】基于粒子群求解CHP机组、气网、电网、储热罐和电锅炉微电网优化模型附matlab代码

1 简介 我国风力发电近年发展迅速,装机容量已成为全球首位.随着风力发电在电力系统中的渗透率不断提高,我国多个地区(尤其是"三北"地区)已经面临着十分严峻的风电消纳问题,产生不容忽视的弃风问题.针对目前我国风电消纳存在的困难,本文提出粒子群优化CHP机组、气网、电网、储热罐和电锅炉微电网控制策略. 2 部分代码 Ppv=[0;0;0;0;0;0;9.86000000000000;19.0100000000000;33.1000000000000;45.0700000000000;64.7900000

qq_59747472的博客 677

CVE-2021-3156本地提权漏洞复现

受影响版本 sudo: 1.8.2 - 1.8.31p2 sudo: 1.9.0 - 1.9.5p1 测试 我这里是在本地centos7上进行测试。 需要目标机器上存在python编译器、目标主机出网或者能上传文件到目标主机。 以非root用户登录系统,并运行如下命令: sudoedit -s / 通常响应一个以 sudoedit: / 开头的报错,多半存在漏洞。 利用 提权脚本: https://www.o2oxy.cn/wp-content/uploa

The current road is different, love needs to distinguish between right and wrong 3784

代码随想录刷题Day15

链表在添加元素和删除元素需要注意next指针的修改顺序,操作不当容易造成节点的丢失。在完成对一些特殊节点的删除(涉及到pre,curr指针)或者反转等操作的时候,可以尝试构造带有一个无用的头节点的链表,这样链表中所有的节点都可以一视同仁操作,而不是对头节点需要考虑很多细节信息,比如是否为空链表,链表是否只有一个节点等需要额外判断。对于处理链表的倒数第N个节点这样的题,可以考虑结合使用栈的数据结构来缓解链表只能单向逐个遍历的缺陷,使用堆栈只需要一次遍历完链表就可以得知倒数第N个节点是什么。

qq_57141819的博客 950

【异常】Cursor报错We‘re having trouble connecting to the model provider. This might be temporary

在使用Cursor编辑器进行AI交互操作时,界面弹出如下报错提示,导致无法正常调用模型服务,影响使用流程:We’re having trouble connecting to the model provider. This might be temporary - please try again in a moment. 该报错核心含义为Cursor编辑器无法正常连接至背后的AI模型服务提供商(如OpenAI、Anthropic等),属于连接类异常,并非编辑器本身运行故障。经排查,该报错不具备破坏性,仅

奶爸的编程之路,也就一周冷个三天 1730

Day63--总结--三周半!速通《代码随想录算法训练营》(附每日计划,思路与代码笔记,可以来跟练)

Day63--总结--三周半!速通《代码随想录算法训练营》(附每日计划,思路与代码笔记,可以来跟练)

m0_60740070的博客 2308

CODESYS数据处理合集(高低字节/ 字/浮点数/位)

VAR_INPUT//字节0//字节1END_VARVAREND_VAR。

RXXW_Dor的博客 365

2026最新华为OD机试新系统机考真题- 真题题库目录|全覆盖题库 + 逐点算法考点详解

2026年4月1日起,华为OD机试正式切换至新系统模式!采用力扣模式,无需自己写输入! 难度大幅度降低。正在备考华为OD机试的同学,优先刷新系统机试真题,可大幅提升通过率。 新系统考题考点与旧版一致,无需重新适应。本专栏所有算法题均配有详细思路解析,并提供C语言、JS、C++、Python、Go、Java多语言源码实现。订阅后私信即可开通专属OJ刷题权限,高效备考一次上岸!

算法大师! 3025

【代码随想录训练营第42期 打卡总结 - 刷题记录】

打卡总结

记得要努力变强 1669

zemax像差参数Ray Fan/Spot Diagram/MTF/....讲解三

zemax像差参数Ray Fan/Spot Diagram/MTF/....讲解三

weixin_72050316的博客 1391

代码随想录带刷day10

例如,在 “abbaca” 中,我们可以删除 “bb” 由于两字母相邻且相同,这是此时唯一可以执行删除操作的重复项。解析:本题题目描述不明确,导致有些情况没想到,初始时看测试用例,感觉可以hash来做,这样能大大节约时间,但是,最后发现测试用例没过,之后去看了。你所使用的语言也许不支持栈。题目描述:给定一个只包括 ‘(’,‘)’,‘{’,‘}’,‘[’,‘]’ 的字符串 s ,判断字符串是否有效。题目描述:给出由小写字母组成的字符串 s,重复项删除操作会选择两个相邻且相同的字母,并删除它们。

qq_64919637的博客 755

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

代码随想录五刷day9

贪心算法

ResNet156的博客 518

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

代码随想录五刷day8

回溯

ResNet156的博客 527

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

Day4 代码随想录 刷题记录

今日共刷1题,用时2h45mins。链表的基础结构与何时用虚拟头结点/虚拟头结点的next 区分得不是很清楚。

windyyyyyyyyyyy的博客 1111

Day9 代码随想录 刷题记录

今日刷题2道,总计用时3h10mins。迭代器的用法不够熟悉,对于表述的部分概念不够理解。同时哈希表的使用,到此 三种方法均已实现过,应该培养对于哈希表运用的敏感度(遇到求元素重复的过程就要往哈希表的方向思考。

windyyyyyyyyyyy的博客 1156

Day2 代码随想录 刷题记录

状态不错。值得反思的是很多基础语法与输入的问题。还有对于边界的把握度不够,基础完成了思路后一定要完成边界的处理,这个点考虑得还不够到位。

windyyyyyyyyyyy的博客 737

代码随想录刷题Day10

这9天慢慢养成刷题习惯,对数组经典问题类型:二分、双指针、移动窗口、模拟螺旋矩阵、数组前缀和,基本过了一遍。二分,前提是数组是有序的,除了用来在数组中按值搜索外,还能加速自然数(自然有序)一些求解过程,比如不用调函数库的方式求解数的平方根;双指针,重要的是定义好两个指针的目的,一般是一个指针用来遍历数组,一个指针是用来处理和题目有关的事情,比如删除数组任务中,维护删除后的指针位置,或者是移动0时维护非零部分等。

qq_57141819的博客 693

Day13 代码随想录 刷题记录

共刷题两道,用时4h左右。KMP算法好难理解,用了一些时间。

windyyyyyyyyyyy的博客 939

Day 3 代码随想录 刷题记录

今日共刷两题,用时2h55mins。链表相关的用法还不是很清晰,可以再学习一下~

windyyyyyyyyyyy的博客 1061

代码随想录刷题Day21

四数之和II分析对象是四个数组,计算四个数组有多少种取值搭配可以使得四个数和为0,由于分析的是四个数组,不涉及到去重操作,以及答案是关于方案的次数,而不是具体的值,可以把原本四层循环遍历求值的题简化为两次的两层循环遍历,依次求出(a+b)并存储下来,求出-(c+d)并查找是否有(a+b) == -(c+d),从而进行统计达到要求的次数。三数之和,是对a逐一遍历,使用双指针来确定b和c的指针,只是要注意,a,b,c的值不能重复,也就是在移动的时候,得是移动到下一个。接下来开启字符串类型的题目刷题。

qq_57141819的博客 1010

Day10 代码随想录 刷题记录

共刷3题,总计用时5h25mins。6.3开始进入旅游状态,休息了几天,零零散散敲了点代码,看了下整体的思路。后面应该要更加大强度,同时跟进相关基础知识的学习。

windyyyyyyyyyyy的博客 899

代码随想录五刷day11

单调栈

ResNet156的博客 385

【Day65】代码随想录总结篇

今天是代码随想录刷题训练营的最后一天,没有题目只是写感想。

格子格鸽的个人博客 800
上一篇: 代码随想录五刷day11
下一篇: CodeTop一刷
乱世在摸鱼
博客等级 码龄6年 618粉丝 296原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

乱世在摸鱼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值