数据结构
CodeBoyWLC
技术+原理爱好者
展开
-
【数据结构】反转链表
package ds; public class DS { public static void main(String[] args) { Node a1 = new Node(1, "A"); Node a2 = new Node(2, "B"); Node a3 = new Node(3, "C"); Node a4 = new Node(4, "D"); DList DL = new DList(); DL.add(a1); DL.add(a2); DL.add(a原创 2021-05-27 22:58:18 · 83 阅读 · 0 评论 -
【数据结构】连续子数组的最大和
package collection; public class HashMapDemo01 { public static void main(String args[]) { System.out.println(solve(new int[] { 1, -3, 3, 10, -4, 7, 2, -5 })); } public static long solve(int[] a) { int len = a.length; if (len == 0) { return .原创 2021-05-27 18:40:43 · 70 阅读 · 0 评论 -
【数据结构】设计LRU缓存
package collection; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; class LRUCache { class SLDode { int key, value; SLDode prev, next; public SLDode() { } public SLDode(int key, int value) { this.key = key; ..原创 2021-05-27 18:38:03 · 73 阅读 · 0 评论 -
【数据结构】DP:最长公共子串问题
给定两个字符串str1和str2,输出两个字符串的最长公共子串 题目保证str1和str2的最长公共子串存在且唯一。 package collection; public class HashMapDemo01 { public static void main(String args[]) { System.out.println(DP( "d8Wt20lnSgAw0HgauN2Kspyr298H6wQWMO3tMNRpWmR25NNTD4VTnq16LX80khSMEG0W5V72cIDL原创 2021-05-27 15:13:15 · 114 阅读 · 0 评论 -
【数据结构】双链表
#include<iostream> #include<cstdlib> using namespace std; typedef struct DuLNode { int data; DuLNode *prior,*next; }; void InitSList(DuLNode *&SL) {//初始化双链表 SL=(DuLNode*)malloc(sizeof(DuLNode)); SL->prior=SL->next=NULL; } void cr原创 2021-04-28 12:28:48 · 88 阅读 · 0 评论