当前位置: 首页 > news >正文

算法-3-基本的数据结构

单双链表

1.单链表双链表如何反转

import java.util.ArrayList;
import java.util.List;public class Code01_ReverseList {public static class Node {public int value;public Node next;public Node(int data) {value = data;}}public static class DoubleNode {public int value;public DoubleNode last;public DoubleNode next;public DoubleNode(int data) {value = data;}}//  head//   a    ->   b    ->  c  ->  null//   c    ->   b    ->  a  ->  nullpublic static Node reverseLinkedList(Node head) {Node pre = null;Node next = null;while (head != null) {next = head.next;head.next = pre;pre = head;head = next;}return pre;}public static DoubleNode reverseDoubleList(DoubleNode head) {DoubleNode pre = null;DoubleNode next = null;while (head != null) {next = head.next;head.next = pre;head.last = next;pre = head;head = next;}return pre;}public static Node testReverseLinkedList(Node head) {if (head == null) {return null;}ArrayList<Node> list = new ArrayList<>();while (head != null) {list.add(head);head = head.next;}list.get(0).next = null;int N = list.size();for (int i = 1; i < N; i++) {list.get(i).next = list.get(i - 1);}return list.get(N - 1);}public static DoubleNode testReverseDoubleList(DoubleNode head) {if (head == null) {return null;}ArrayList<DoubleNode> list = new ArrayList<>();while (head != null) {list.add(head);head = head.next;}list.get(0).next = null;DoubleNode pre = list.get(0);int N = list.size();for (int i = 1; i < N; i++) {DoubleNode cur = list.get(i);cur.last = null;cur.next = pre;pre.last = cur;pre = cur;}return list.get(N - 1);}// for testpublic static Node generateRandomLinkedList(int len, int value) {int size = (int) (Math.random() * (len + 1));if (size == 0) {return null;}size--;Node head = new Node((int) (Math.random() * (value + 1)));Node pre = head;while (size != 0) {Node cur = new Node((int) (Math.random() * (value + 1)));pre.next = cur;pre = cur;size--;}return head;}// for testpublic static DoubleNode generateRandomDoubleList(int len, int value) {int size = (int) (Math.random() * (len + 1));if (size == 0) {return null;}size--;DoubleNode head = new DoubleNode((int) (Math.random() * (value + 1)));DoubleNode pre = head;while (size != 0) {DoubleNode cur = new DoubleNode((int) (Math.random() * (value + 1)));pre.next = cur;cur.last = pre;pre = cur;size--;}return head;}// for testpublic static List<Integer> getLinkedListOriginOrder(Node head) {List<Integer> ans = new ArrayList<>();while (head != null) {ans.add(head.value);head = head.next;}return ans;}// for testpublic static boolean checkLinkedListReverse(List<Integer> origin, Node head) {for (int i = origin.size() - 1; i >= 0; i--) {if (!origin.get(i).equals(head.value)) {return false;}head = head.next;}return true;}// for testpublic static List<Integer> getDoubleListOriginOrder(DoubleNode head) {List<Integer> ans = new ArrayList<>();while (head != null) {ans.add(head.value);head = head.next;}return ans;}// for testpublic static boolean checkDoubleListReverse(List<Integer> origin, DoubleNode head) {DoubleNode end = null;for (int i = origin.size() - 1; i >= 0; i--) {if (!origin.get(i).equals(head.value)) {return false;}end = head;head = head.next;}for (int i = 0; i < origin.size(); i++) {if (!origin.get(i).equals(end.value)) {return false;}end = end.last;}return true;}// for testpublic static void main(String[] args) {int len = 50;int value = 100;int testTime = 100000;System.out.println("test begin!");for (int i = 0; i < testTime; i++) {Node node1 = generateRandomLinkedList(len, value);List<Integer> list1 = getLinkedListOriginOrder(node1);node1 = reverseLinkedList(node1);if (!checkLinkedListReverse(list1, node1)) {System.out.println("Oops1!");}Node node2 = generateRandomLinkedList(len, value);List<Integer> list2 = getLinkedListOriginOrder(node2);node2 = testReverseLinkedList(node2);if (!checkLinkedListReverse(list2, node2)) {System.out.println("Oops2!");}DoubleNode node3 = generateRandomDoubleList(len, value);List<Integer> list3 = getDoubleListOriginOrder(node3);node3 = reverseDoubleList(node3);if (!checkDoubleListReverse(list3, node3)) {System.out.println("Oops3!");}DoubleNode node4 = generateRandomDoubleList(len, value);List<Integer> list4 = getDoubleListOriginOrder(node4);node4 = reverseDoubleList(node4);if (!checkDoubleListReverse(list4, node4)) {System.out.println("Oops4!");}}System.out.println("test finish!");}}

2.把定值都删除掉

是n就跳过,不是n next指向

public class Code02_DeleteGivenValue {public static class Node {public int value;public Node next;public Node(int data) {this.value = data;}}// head = removeValue(head, 2);public static Node removeValue(Node head, int num) {// head来到第一个不需要删的位置while (head != null) {if (head.value != num) {break;}head = head.next;}// 1 ) head == null// 2 ) head != nullNode pre = head;Node cur = head;while (cur != null) {if (cur.value == num) {pre.next = cur.next;} else {pre = cur;}cur = cur.next;}return head;}}

队列跟栈

双链表实现

import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;public class Code03_DoubleEndsQueueToStackAndQueue {public static class Node<T> {public T value;public Node<T> last;public Node<T> next;public Node(T data) {value = data;}}public static class DoubleEndsQueue<T> {public Node<T> head;public Node<T> tail;public void addFromHead(T value) {Node<T> cur = new Node<T>(value);if (head == null) {head = cur;tail = cur;} else {cur.next = head;head.last = cur;head = cur;}}public void addFromBottom(T value) {Node<T> cur = new Node<T>(value);if (head == null) {head = cur;tail = cur;} else {cur.last = tail;tail.next = cur;tail = cur;}}public T popFromHead() {if (head == null) {return null;}Node<T> cur = head;if (head == tail) {head = null;tail = null;} else {head = head.next;cur.next = null;head.last = null;}return cur.value;}public T popFromBottom() {if (head == null) {return null;}Node<T> cur = tail;if (head == tail) {head = null;tail = null;} else {tail = tail.last;tail.next = null;cur.last = null;}return cur.value;}public boolean isEmpty() {return head == null;}}public static class MyStack<T> {private DoubleEndsQueue<T> queue;public MyStack() {queue = new DoubleEndsQueue<T>();}public void push(T value) {queue.addFromHead(value);}public T pop() {return queue.popFromHead();}public boolean isEmpty() {return queue.isEmpty();}}public static class MyQueue<T> {private DoubleEndsQueue<T> queue;public MyQueue() {queue = new DoubleEndsQueue<T>();}public void push(T value) {queue.addFromHead(value);}public T poll() {return queue.popFromBottom();}public boolean isEmpty() {return queue.isEmpty();}}public static boolean isEqual(Integer o1, Integer o2) {if (o1 == null && o2 != null) {return false;}if (o1 != null && o2 == null) {return false;}if (o1 == null && o2 == null) {return true;}return o1.equals(o2);}public static void main(String[] args) {int oneTestDataNum = 100;int value = 10000;int testTimes = 100000;for (int i = 0; i < testTimes; i++) {MyStack<Integer> myStack = new MyStack<>();MyQueue<Integer> myQueue = new MyQueue<>();Stack<Integer> stack = new Stack<>();Queue<Integer> queue = new LinkedList<>();for (int j = 0; j < oneTestDataNum; j++) {int nums = (int) (Math.random() * value);if (stack.isEmpty()) {myStack.push(nums);stack.push(nums);} else {if (Math.random() < 0.5) {myStack.push(nums);stack.push(nums);} else {if (!isEqual(myStack.pop(), stack.pop())) {System.out.println("oops!");}}}int numq = (int) (Math.random() * value);if (stack.isEmpty()) {myQueue.push(numq);queue.offer(numq);} else {if (Math.random() < 0.5) {myQueue.push(numq);queue.offer(numq);} else {if (!isEqual(myQueue.poll(), queue.poll())) {System.out.println("oops!");}}}}}System.out.println("finish!");}}

数组实现

public class Code04_RingArray {public static class MyQueue {private int[] arr;private int pushi;// endprivate int polli;// beginprivate int size;private final int limit;public MyQueue(int limit) {arr = new int[limit];pushi = 0;polli = 0;size = 0;this.limit = limit;}public void push(int value) {if (size == limit) {throw new RuntimeException("队列满了,不能再加了");}size++;arr[pushi] = value;pushi = nextIndex(pushi);}public int pop() {if (size == 0) {throw new RuntimeException("队列空了,不能再拿了");}size--;int ans = arr[polli];polli = nextIndex(polli);return ans;}public boolean isEmpty() {return size == 0;}// 如果现在的下标是i,返回下一个位置private int nextIndex(int i) {return i < limit - 1 ? i + 1 : 0;}}}

实现一个特殊的栈,在基本功能基础上,再实现返回栈中最小元素的功能

1.pop,push,getMin,操作的时间复杂度都是O(1)

2.设计的栈类型可以使用现成的栈结构

同步压入,同步弹出

import java.util.Stack;public class Code05_GetMinStack {public static class MyStack1 {private Stack<Integer> stackData;private Stack<Integer> stackMin;public MyStack1() {this.stackData = new Stack<Integer>();this.stackMin = new Stack<Integer>();}public void push(int newNum) {if (this.stackMin.isEmpty()) {this.stackMin.push(newNum);} else if (newNum <= this.getmin()) {this.stackMin.push(newNum);}this.stackData.push(newNum);}public int pop() {if (this.stackData.isEmpty()) {throw new RuntimeException("Your stack is empty.");}int value = this.stackData.pop();if (value == this.getmin()) {this.stackMin.pop();}return value;}public int getmin() {if (this.stackMin.isEmpty()) {throw new RuntimeException("Your stack is empty.");}return this.stackMin.peek();}}public static class MyStack2 {private Stack<Integer> stackData;private Stack<Integer> stackMin;public MyStack2() {this.stackData = new Stack<Integer>();this.stackMin = new Stack<Integer>();}public void push(int newNum) {if (this.stackMin.isEmpty()) {this.stackMin.push(newNum);} else if (newNum < this.getmin()) {this.stackMin.push(newNum);} else {int newMin = this.stackMin.peek();this.stackMin.push(newMin);}this.stackData.push(newNum);}public int pop() {if (this.stackData.isEmpty()) {throw new RuntimeException("Your stack is empty.");}this.stackMin.pop();return this.stackData.pop();}public int getmin() {if (this.stackMin.isEmpty()) {throw new RuntimeException("Your stack is empty.");}return this.stackMin.peek();}}public static void main(String[] args) {MyStack1 stack1 = new MyStack1();stack1.push(3);System.out.println(stack1.getmin());stack1.push(4);System.out.println(stack1.getmin());stack1.push(1);System.out.println(stack1.getmin());System.out.println(stack1.pop());System.out.println(stack1.getmin());System.out.println("=============");MyStack1 stack2 = new MyStack1();stack2.push(3);System.out.println(stack2.getmin());stack2.push(4);System.out.println(stack2.getmin());stack2.push(1);System.out.println(stack2.getmin());System.out.println(stack2.pop());System.out.println(stack2.getmin());}}

如何使用栈结构实现队列结构

import java.util.Stack;public class Code06_TwoStacksImplementQueue {public static class TwoStacksQueue {public Stack<Integer> stackPush;public Stack<Integer> stackPop;public TwoStacksQueue() {stackPush = new Stack<Integer>();stackPop = new Stack<Integer>();}// push栈向pop栈倒入数据private void pushToPop() {if (stackPop.empty()) {while (!stackPush.empty()) {stackPop.push(stackPush.pop());}}}public void add(int pushInt) {stackPush.push(pushInt);pushToPop();}public int poll() {if (stackPop.empty() && stackPush.empty()) {throw new RuntimeException("Queue is empty!");}pushToPop();return stackPop.pop();}public int peek() {if (stackPop.empty() && stackPush.empty()) {throw new RuntimeException("Queue is empty!");}pushToPop();return stackPop.peek();}}public static void main(String[] args) {TwoStacksQueue test = new TwoStacksQueue();test.add(1);test.add(2);test.add(3);System.out.println(test.peek());System.out.println(test.poll());System.out.println(test.peek());System.out.println(test.poll());System.out.println(test.peek());System.out.println(test.poll());}}

如何使用队列结构实现栈结构

import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;public class Code07_TwoQueueImplementStack {public static class TwoQueueStack<T> {public Queue<T> queue;public Queue<T> help;public TwoQueueStack() {queue = new LinkedList<>();help = new LinkedList<>();}public void push(T value) {queue.offer(value);}public T poll() {while (queue.size() > 1) {help.offer(queue.poll());}T ans = queue.poll();Queue<T> tmp = queue;queue = help;help = tmp;return ans;}public T peek() {while (queue.size() > 1) {help.offer(queue.poll());}T ans = queue.poll();help.offer(ans);Queue<T> tmp = queue;queue = help;help = tmp;return ans;}public boolean isEmpty() {return queue.isEmpty();}}public static void main(String[] args) {System.out.println("test begin");TwoQueueStack<Integer> myStack = new TwoQueueStack<>();Stack<Integer> test = new Stack<>();int testTime = 1000000;int max = 1000000;for (int i = 0; i < testTime; i++) {if (myStack.isEmpty()) {if (!test.isEmpty()) {System.out.println("Oops");}int num = (int) (Math.random() * max);myStack.push(num);test.push(num);} else {if (Math.random() < 0.25) {int num = (int) (Math.random() * max);myStack.push(num);test.push(num);} else if (Math.random() < 0.5) {if (!myStack.peek().equals(test.peek())) {System.out.println("Oops");}} else if (Math.random() < 0.75) {if (!myStack.poll().equals(test.pop())) {System.out.println("Oops");}} else {if (myStack.isEmpty() != test.isEmpty()) {System.out.println("Oops");}}}}System.out.println("test finish!");}}

Master 公式求递推的时间复杂度

前提,子问题规模一致,(比如,子问题是分两个二分之N区间分别求最大值,可以Master,若分为三分之N那就不行)

公式:T(N)=a*T(N/b)+O(N的d次方)

得到abd之后

求最大值

public class Code08_GetMax {// 求arr中的最大值public static int getMax(int[] arr) {return process(arr, 0, arr.length - 1);}// arr[L..R]范围上求最大值  L ... R   Npublic static int process(int[] arr, int L, int R) {// arr[L..R]范围上只有一个数,直接返回,base caseif (L == R) { return arr[L];}// L...R 不只一个数// mid = (L + R) / 2int mid = L + ((R - L) >> 1); // 中点   	1int leftMax = process(arr, L, mid);int rightMax = process(arr, mid + 1, R);return Math.max(leftMax, rightMax);}}

哈希

import java.util.HashMap;
import java.util.HashSet;
import java.util.TreeMap;public class HashMapAndSortedMap {public static class Node {public int value;public Node(int v) {value = v;}}public static class Zuo {public int value;public Zuo(int v) {value = v;}}public static void main(String[] args) {HashMap<Integer, String> test = new HashMap<>();Integer a = 19000000;Integer b = 19000000;System.out.println(a == b);test.put(a, "我是3");System.out.println(test.containsKey(b));Zuo z1 = new Zuo(1);Zuo z2 = new Zuo(1);HashMap<Zuo, String> test2 = new HashMap<>();test2.put(z1, "我是z1");System.out.println(test2.containsKey(z2));// UnSortedMapHashMap<Integer, String> map = new HashMap<>();map.put(1000000, "我是1000000");map.put(2, "我是2");map.put(3, "我是3");map.put(4, "我是4");map.put(5, "我是5");map.put(6, "我是6");map.put(1000000, "我是1000001");System.out.println(map.containsKey(1));System.out.println(map.containsKey(10));System.out.println(map.get(4));System.out.println(map.get(10));map.put(4, "他是4");System.out.println(map.get(4));map.remove(4);System.out.println(map.get(4));// keyHashSet<String> set = new HashSet<>();set.add("abc");set.contains("abc");set.remove("abc");// 哈希表,增、删、改、查,在使用时,O(1)System.out.println("=====================");Integer c = 100000;Integer d = 100000;System.out.println(c.equals(d));Integer e = 127; // - 128 ~ 127Integer f = 127;System.out.println(e == f);HashMap<Node, String> map2 = new HashMap<>();Node node1 = new Node(1);Node node2 = node1;map2.put(node1, "我是node1");map2.put(node2, "我是node1");System.out.println(map2.size());System.out.println("======================");// TreeMap 有序表:接口名// 红黑树、avl、sb树、跳表// O(logN)System.out.println("有序表测试开始");TreeMap<Integer, String> treeMap = new TreeMap<>();treeMap.put(3, "我是3");treeMap.put(4, "我是4");treeMap.put(8, "我是8");treeMap.put(5, "我是5");treeMap.put(7, "我是7");treeMap.put(1, "我是1");treeMap.put(2, "我是2");System.out.println(treeMap.containsKey(1));System.out.println(treeMap.containsKey(10));System.out.println(treeMap.get(4));System.out.println(treeMap.get(10));treeMap.put(4, "他是4");System.out.println(treeMap.get(4));// treeMap.remove(4);System.out.println(treeMap.get(4));System.out.println("新鲜:");System.out.println(treeMap.firstKey());System.out.println(treeMap.lastKey());// <= 4System.out.println(treeMap.floorKey(4));// >= 4System.out.println(treeMap.ceilingKey(4));// O(logN)}}

 

相关文章:

算法-3-基本的数据结构

单双链表 1.单链表双链表如何反转 import java.util.ArrayList; import java.util.List;public class Code01_ReverseList {public static class Node {public int value;public Node next;public Node(int data) {value data;}}public static class DoubleNode {public int…...

探秘Java反射:灵活编程的利器

前言 大家好&#xff0c;我是chowley&#xff0c;不知道大家在学习Java的过程中有没有听过反射的概念&#xff0c;今天我来总结一下我心中的Java反射。 在Java编程中&#xff0c;反射是一种强大的工具&#xff0c;它允许程序在运行时检查和操作类、方法、属性等&#xff0c;而…...

记录 | ubuntu pyqt5 pycharm配置

Ubuntu16.04pycharmpyqt5安装与配置_ubuntu pycharm pyqt5-CSDN博客pycharm激活码 6ZUMD7WWWU-eyJsaWNlbnNlSWQiOiI2WlVNRDdXV1dVIiwibGljZW5zZWVOYW1lIjoiSmV0cyBHcm91cCIsImFzc2lnbmVlTmFtZSI6IiIsImFzc2lnbmVlRW1haWwiOiIiLCJsaWNlbnNlUmVzdHJpY3Rpb24iOiIiLCJjaGVja0NvbmN…...

ESP32学习(1)——环境搭建

使用的ESP32板子如下图所示 它可以用Arduino 软件&#xff0c;基于C语言开发。但是&#xff0c;在这里&#xff0c;我是用Thonny软件&#xff0c;基于micro_python对其进行开发。 1.安装Thonny Thonny的软件安装包&#xff0c;可以去它官网上下载。Thonny, Python IDE for begi…...

Attention Is All Your Need论文笔记

论文解决了什么问题&#xff1f; 提出了一个新的简单网络架构——transformer&#xff0c;仅仅是基于注意力机制&#xff0c;完全免去递推和卷积&#xff0c;使得神经网络训练地速度极大地提高。 We propose a new simple network architecture, the Transformer, based sole…...

vue-进阶语法(四)

目录 v-model原理 v-model应用于组件 sync修饰符 ref 和 $refs&#xff08;重点&#xff09; $nextTick v-model原理 原理&#xff1a;v-model本质上是一个语法糖。例如应用在输入框上&#xff0c;就是 value属性 和 input事件 的合写。 作用&#xff1a;提供数据的双向…...

CGAL::2D Arrangements-7

7 几何Traits 几何Traits封装了几何实体的定义以及处理这些几何实体的几何predicates和构造的实现&#xff0c;供Arrangement_on_surface_2类模板和其他周边模块使用。应用于Arrangement的各种算法所确定的最小要求被组织在精细几何特征概念的层次中。每个概念列出的需求只包括…...

linux系统下vscode portable版本的rust环境搭建004:rust

目的&#xff1a;希望在获得一个新的系统之后&#xff0c;以最简便快速的方式搭配一个rust的编程环境命令在线安装只执行这句就行了 &#xff1a;curl --proto https --tlsv1.2 -sSf https://sh.rustup.rs | sh&#xff0c;因为是要portable安装所以按照以下的方式执行。 下载…...

从汇编角度解释线程间互斥-mutex互斥锁与lock_guard的使用

多线程并发的竞态问题 我们创建三个线程同时进行购票&#xff0c;代码如下 #include<iostream> #include<thread> #include<list> using namespace std; //总票数 int ticketCount100; //售票线程 void sellTicket(int idx) {while(ticketCount>0){cou…...

高程 | 多态性(c++)

文章目录 &#x1f4da;多态&#x1f4da;运算符重载&#x1f407;定义&#x1f407;规则&#x1f407;友元运算符重载函数&#x1f407;成员运算符重载函数 &#x1f4da;虚函数&#x1f4da;纯虚函数和抽象类 &#x1f4da;多态 多态&#xff1a;同样的消息被不同类型的对象…...

LV.23 D2 开发环境搭建及平台介绍 学习笔记

一、Keil MDK-ARM简介及安装 Keil MDK&#xff0c;也称MDK-ARM&#xff0c;Realview MDK &#xff08;Microcontroller Development Kit&#xff09;等。目前Keil MDK 由三家国内代理商提供技术支持和相关服务。 MDK-ARM软件为基于Cortex-M、Cortex-R4、ARM7、ARM9处理器设备…...

[uniapp生命周期]详细讲解uniapp中那些属于vue生命周期,那些属于uniapp独有的生命周期,以及这中间的区别 相关的内容和api 代码注释

目录 1. Vue.js生命周期函数2.Vue生命周期函数代码beforeCreatecreatedbeforeMountmountedbeforeUpdateupdatedbeforeDestroydestroyed$nextTick$forceUpdate$destroy 3. UniApp独有的生命周期函数onLaunchonShowonHideonError 4.总结 在UniApp中&#xff0c;除了Vue.js的生命周…...

【动态规划】【记忆化搜索】【状态压缩】1681. 最小不兼容性

作者推荐 【数位dp】【动态规划】【状态压缩】【推荐】1012. 至少有 1 位重复的数字 本文涉及知识点 动态规划汇总 状态压缩 记忆化搜索 1681. 最小不兼容性 给你一个整数数组 nums​​​ 和一个整数 k 。你需要将这个数组划分到 k 个相同大小的子集中&#xff0c;使得同一…...

JVM-类加载器 双亲委派机制

申明&#xff1a;文章内容是本人学习极客时间课程所写&#xff0c;文字和图片基本来源于课程资料&#xff0c;在某些地方会插入一点自己的理解&#xff0c;未用于商业用途&#xff0c;侵删。 什么是JVM JVM是Java Virtual Machine&#xff08;Java虚拟机&#xff09;的缩写&a…...

vue axios 请求后端无法传参问题

vue请求后端无法传参问题 问题描述处理过程总结 问题描述 在学习vue时&#xff0c;使用axios调用后端&#xff0c;发现无法把参数正确传到后端&#xff0c;现象如下&#xff1a; 使用vue发起请求&#xff0c;浏览器上已经有传参&#xff0c;但是后端没接收到对应的用户名密码&…...

打印最小公倍数

打印最小公倍数 题目描述&#xff1a; 输入2个整数m和n&#xff0c;计算m和n的最小公倍数&#xff0c;并打印出结果 测试1&#xff1a; 输入&#xff1a;18 24 输出&#xff1a;72 测试2&#xff1a; 输入&#xff1a;18 6 输出&#xff1a;18解法思路: 最小公倍数是指两个…...

[AIGC] Java 和 Kotlin 的区别

好的&#xff0c;我还是以“萌萌哒小码农”的身份继续回答您的问题。 Java 和 Kotlin 是两种不同的编程语言&#xff0c;它们有许多共同点&#xff0c;但也有一些重要的区别。以下是一些常见的 Java 和 Kotlin 的区别&#xff1a; 语法 Kotlin 的语法比 Java 简洁得多&#…...

蓝桥杯电子类单片机提升一——超声波测距

前言 单片机资源数据包_2023 一、超声波测距原理 二、超声波测距的应用 1.超声波的发射 2.单片机知识补充&#xff1a;定时器 3.超声波的接收与计时 4.距离的计算 1&#xff09;定时器1为16位自动重载&#xff0b;1T11.0592MHz 2&#xff09;定时器1为16位自动重载&am…...

前端架构: 脚手架开发流程中的难点梳理

脚手架的开发流程 1 &#xff09;开发流程 创建 npm 项目创建脚手架入口文件&#xff0c;最上方添加&#xff1a; #!/usr/bin/env node 配置 package.json, 添加 bin 属性编写脚手架代码将脚手架发布到 npm 2 &#xff09;使用流程 安装脚手架 npm install -g your-own-cli …...

django中配置使用websocket

Django 默认情况下并不支持 WebSocket&#xff0c;但你可以通过集成第三方库如 channels 来实现 WebSocket 功能。channels 是一个 Django 应用&#xff0c;它提供了对 WebSocket、HTTP2 和其他协议的支持。 下面是如何在 Django 项目中使用 WebSocket 的基本步骤&#xff1a;…...

Rust复合类型详解

在Rust中&#xff0c;复合类型是一种能够将多个值组合在一起的数据类型。本篇博客将介绍两种常见的复合类型&#xff1a;元组&#xff08;Tuple&#xff09;和数组&#xff08;Array&#xff09;。 Tuple&#xff08;元组&#xff09; 元组是Rust中的一种复合类型&#xff0c…...

学习 JavaScript 闭包

1. 前言 闭包是 JavaScript 中一种非常重要的概念&#xff0c;它允许函数访问其外部作用域中的变量&#xff0c;即使在函数被返回或者在其原始定义的作用域之外执行时仍然可以访问这些变量。 在讲解闭包之前我们得弄清楚下面的概念&#xff1a; 作用域链&#xff1a; JavaSc…...

VScode中配置 C/C++ 环境 | IT拯救者

文章目录 0 引言1. 下载编辑器VScode2. 下载编译器MinGW并解压3. 将MinGW添加至环境变量4. 配置VScode插件5. 运行代码6. 调整和优化7. 提示8. 例行格式条款9. 例行格式条款 0 引言 由于VScode毛毛张使用不习惯&#xff0c;因此配置教程记不住&#xff0c;不过毛毛张看到一篇不…...

基于Python实现Midjourney集成到(个人/公司)平台中

目前Midjourney没有对外开放Api&#xff0c;想体验他们的服务只能在discord中进入他们的频道进行体验或者把他们的机器人拉入自己创建的服务器中&#xff1b;而且现在免费的也用不了了&#xff0c;想使用就得订阅。本教程使用midjourney-api这个开源项目&#xff0c;搭建Midjou…...

蓝桥杯刷题--python-6

0最大距离 - 蓝桥云课 (lanqiao.cn) n=int(input()) nums=list(map(int,input().split()))max_=float(-inf) for i in range (n):for j in range (i+1,n):tmp=abs(i-j)+abs(nums[i]-nums[j])max_=max(tmp,max_) print(max_) 0最长递增 - 蓝桥云课 (lanqiao.cn) import os im…...

node+vue3+mysql前后分离开发范式——实现对数据库表的增删改查

文章目录 ⭐前言⭐ 功能设计与实现💖 node后端操作数据库实现增删改查💖 vue3前端实现增删改查⭐ 效果⭐ 总结⭐ 结束⭐结束⭐前言 大家好,我是yma16,本文分享关于 node+vue3+mysql前后分离开发范式——实现对数据库表的增删改查。 技术选型 前端:vite+vue3+antd 后端:…...

【Android】使用Apktool反编译Apk文件

文章目录 1. 下载Apktool1.1 Apktool官网下载1.2 百度网盘下载 2. 安装Apktool3. 使用Apktool3.1 配置Java环境3.2 准备Apk文件3.3 反编译Apk文件3.3.1 解包Apk文件3.3.2 修改Apk文件3.3.3 打包Apk文件3.3.4 签名Apk文件 1. 下载Apktool 要使用Apktool&#xff0c;需要准备好 …...

(04)Hive的相关概念——order by 、sort by、distribute by 、cluster by

Hive中的排序通常涉及到order by 、sort by、distribute by 、cluster by 一、语法 selectcolumn1,column2, ... from table [where 条件] [group by column] [order by column] [cluster by column| [distribute by column] [sort by column] [limit [offset,] rows]; …...

Django模板(二)

标签if 标签在渲染过程中提供使用逻辑的方法,比如:if和for 标签被 {% 和 %} 包围,如下所示: 由于在模板中,没有办法通过代码缩进判断代码块,所以控制标签都需要有结束的标签 if判断标签{% if %} {% endif %} : # athlete_list 不为空 {% if athlete_list %}# 输出 ath…...

勒索病毒最新变种.faust勒索病毒来袭,如何恢复受感染的数据?

引言&#xff1a; 随着我们进入数字化时代&#xff0c;数据的重要性变得愈发显著&#xff0c;而网络安全威胁也日益增加。.faust勒索病毒是其中一种备受恶意分子钟爱的危险工具&#xff0c;它通过加密用户文件并勒索高额赎金来对个人和组织发起攻击。本文将深入探讨.faust勒索…...

python 人脸检测器

import cv2# 加载人脸检测器 关键文件 haarcascade_frontalface_default.xml face_cascade cv2.CascadeClassifier(haarcascade_frontalface_default.xml)# 读取图像 分析图片 ren4.png image cv2.imread(ren4.png) gray cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)# 进行人脸…...

机器学习与深度学习

什么是机器学习 机器学习是一门跨学科的学科&#xff0c;它致力于研究和开发让计算机能够模拟人类学习行为的技术和方法。机器学习涉及多个学科的知识&#xff0c;如概率论、统计学、逼近论、凸分析、算法复杂度理论等&#xff0c;这些学科为机器学习提供了理论基础和数学工具…...

算法训练营day27(补),贪心算法1

import "sort" //455. 分发饼干 func findContentChildren(g []int, s []int) int { sort.Ints(g) sort.Ints(s) // g代表胃口数组&#xff0c; s代表饼干数组 count : 0 // 统计数量 //饼干下标 index : len(s) - 1 // 胃口循环 for i : len(g) - 1; i > 0; i--…...

[office] excel2003限定单元格输入值范围教程 #微信#经验分享

excel2003限定单元格输入值范围教程 在Excel中录入数据前都会设置单元格的一些格式&#xff0c;其中会有限定单元格输入值范围的需求&#xff0c;或许有的朋友并不知道单元格该如何限定输入范围&#xff0c;如果不懂的朋友欢迎一起来学习研究。下面是小编带来的关于excel2003限…...

OLED显示红外遥控键码

基本原理 本遥控器的编码是NEC编码&#xff0c;为PWM&#xff08;脉冲宽度调制&#xff09;。 发射红外载波的时间固定&#xff0c;通过改变不发射载波的时间来改变占空比。 逻辑“0”是由0.56ms的38KHZ载波和0.560ms的无载波间隔组成&#xff1b;逻辑“1”是由0.56ms的38KHZ…...

LabVIEW智能温度监控系统

LabVIEW智能温度监控系统 介绍了一个基于LabVIEW的智能温度监控系统&#xff0c;实现对工业环境中温度的实时监控与调控。通过集成传感器技术和LabVIEW软件平台&#xff0c;系统能够自动检测环境温度&#xff0c;及时响应温度变化&#xff0c;并通过图形用户界面(GUI)为用户提…...

专业140+总分420+浙江大学842信号系统与数字电路考研经验电子信息与通信,真题,大纲,参考书。

今年考研已经结束&#xff0c;初试专业课842信号系统与数字电路140&#xff0c;总分420&#xff0c;很幸运实现了自己的目标&#xff0c;被浙大录取&#xff0c;这在高考是想都不敢想的学校&#xff0c;在考研时实现了&#xff0c;所以大家也要有信心&#xff0c;通过自己努力实…...

C语言学习day15:数组强化训练

题目一&#xff1a; 称体重&#xff1a;分别给10个值&#xff0c;来获得最大值 思路&#xff1a; 定义数组&#xff0c;给数组内赋10个值第一个下标的值与第二个下标的值进行比较定义max&#xff0c;将比较得来的较大的值赋值给max一直比较直到比较到最后一个下标&#xff0…...

缓存穿透、缓存击穿与缓存雪崩

缓存穿透、缓存击穿与缓存雪崩 1.本质区别 缓存穿透指的是数据库不存在数据&#xff0c;导致无法缓存&#xff0c;每次查询都查数据库&#xff0c;数据库压垮 缓存击穿指的是缓存键值对key过期了&#xff0c;key过期期间&#xff0c;大量请求访问&#xff0c;不经过缓存&…...

一周学会Django5 Python Web开发-项目配置settings.py文件-模版配置

锋哥原创的Python Web开发 Django5视频教程&#xff1a; 2024版 Django5 Python web开发 视频教程(无废话版) 玩命更新中~_哔哩哔哩_bilibili2024版 Django5 Python web开发 视频教程(无废话版) 玩命更新中~共计17条视频&#xff0c;包括&#xff1a;2024版 Django5 Python we…...

CF1845 D. Rating System [思维题+数形结合]

传送门:CF [前题提要]:自己在做这道题的时候思路完全想错方向,导致怎么做都做不出来,看了题解之后感觉数形结合的思考方式挺好的(或者这种做法挺典的),故写篇题解记录一下 题目很简单,不再解释.先不考虑 k k k,想想是一种什么情况?很显然应该是跟下图一样是一个折线图的变化.…...

HeidiSQL安装配置(基于小皮面板(phpstudy))连接MySQL

下载资源 对于这款图形化工具&#xff0c;博主建议通过小皮面板&#xff08;phpstudy&#xff09;来下载即可&#xff0c;也是防止你下载到钓鱼软件&#xff0c;小皮面板&#xff08;phpstudy&#xff09;如果你不懂是什么&#xff0c;请看下面链接这篇博客 第二篇&#xff1a;…...

【蓝桥2013】错误票据

错误票据 题目描述 某涉密单位下发了某种票据&#xff0c;并要在年终全部收回。 每张票据有唯一的 ID 号。全年所有票据的 ID 号是连续的&#xff0c;但 ID 的开始数码是随机选定的。 因为工作人员疏忽&#xff0c;在录入 ID 号的时候发生了一处错误&#xff0c;造成了某个…...

nvm对node版本进行管理及疑难解决,vue项目搭建与启动

一、nvm安装与node版本管理 nvm安装 1、nvm地址&#xff1a;https://github.com/coreybutler/nvm-windows/releases 2、无需配置安装包&#xff0c;nvm-setup-v1.1.10.zip 解压后双击nvm-setup.exe&#xff0c;选择安装路径&#xff0c;一路next即可 打开dos窗口输入nvm vers…...

Redisson分布式锁 原理 + 运用 记录

Redisson 分布式锁 简单入门 pom <dependency><groupId>org.redisson</groupId><artifactId>redisson</artifactId><version>3.13.6</version></dependency>配置类 package com.hmdp.config;import org.redisson.Redisson;…...

Spring Boot 笔记 021 项目部署

1.1 引入坐标&#xff0c;并双击package打包成jar包 1.2 在服务器上运行jar包 1.3 使用postman测试 2.1 运行配置 2.1.1 命令更改端口 java -jar big-event-1.0-SNAPSHOT.jar --server.port7777 2.1.2 环境变量更新&#xff08;略&#xff09; 2.1.3 外部配置文件&#xff0c…...

新技术革命开始了,Sora一出,所有的视频人、电影人都下岗

Sora一出&#xff0c;所有的视频人、电影人都下岗&#xff01; Sora直接用文本制作长达60秒的视频长镜头&#xff0c;也就是说&#xff0c;将来&#xff0c;只需要输入分镜脚本&#xff0c;电影就可以制作出来&#xff0c;不再需要几十人几百人声势浩大地去“拍”了&#xff0c…...

【FPGA开发】Modelsim和Vivado的使用

本篇文章包含的内容 一、FPGA工程文件结构二、Modelsim的使用三、Vivado的使用3.1 建立工程3.2 分析 RTL ANALYSIS3.2.1 .xdc约束&#xff08;Constraints&#xff09;文件的产生 3.3 综合 SYNTHESIS3.4 执行 IMPLEMENTATION3.5 烧录程序3.6 程序固化3.6.1 SPI约束3.6.2 .bin文…...

现代浏览器对 es模块 【esm】原生支持

现代浏览器对 ES&#xff08;ECMAScript&#xff09;模块的原生支持是指浏览器可以直接解析和执行 JavaScript 文件中的 ES 模块语法&#xff0c;无需额外的工具或转换。 具体来说&#xff0c;当浏览器遇到 import 和 export 关键字时&#xff0c;会将其识别为 ES 模块语法&…...

修改SpringBoot中默认依赖版本

例如SpringBoot2.7.2中ElasticSearch版本是7.17.4 我希望把它变成7.6.1...