classListNode{int val;ListNode next;publicListNode(){}publicListNode(int val){this.val = val;}publicListNode(int val,ListNode next){this.val = val;this.next = next;}}classMyLinkedList{//size存储链表元素的个数int size;//虚拟头节点ListNode head;//初始化链表publicMyLinkedList(){
size =0;
head =newListNode(0);}//获取第index个节点的数值,注意index是从0开始的,第0个节点就是头结点publicintget(int index){if(index <0|| index >= size){return-1;}//当前指针先指向虚拟头节点ListNode cur = head;for(int i =0; i <= index; i++){
cur = cur.next;}return cur.val;}//在链表最前面插入一个节点,等价于在第0个元素前添加publicvoidaddAtHead(int val){addAtIndex(0, val);}publicvoidaddAtTail(int val){addAtIndex(size, val);}publicvoidaddAtIndex(int index,int val){if(index > size){return;}if(index <0){
index =0;}
size++;ListNode pre = head;for(int i =0; i < index; i++){//举个极端的在末尾插入的例子,如数组[1],在index为1处插入元素,循环结束会出现pre指向null的情况,导致引用失效,所以i不能=index
pre = pre.next;}ListNode toAdd =newListNode(val);
toAdd.next = pre.next;
pre.next = toAdd;}publicvoiddeleteAtIndex(int index){if(index <0|| index >= size){return;}
size--;if(index ==0){
head = head.next;return;}ListNode pre = head;for(int i =0; i < index; i++){//极端例子,考虑到pre和pre.next都不能为空;如[1,2,3]删除index为2的元素,
pre = pre.next;}
pre.next = pre.next.next;}}/**
* Your MyLinkedList object will be instantiated and called as such:
* MyLinkedList obj = new MyLinkedList();
* int param_1 = obj.get(index);
* obj.addAtHead(val);
* obj.addAtTail(val);
* obj.addAtIndex(index,val);
* obj.deleteAtIndex(index);
*/
文章目录 AbstractIntroduction不稳定性问题下游任务需要的高分辨率问题解决内存问题- Related WorksLanguage networks and scaling upVision networks and scaling upTransferring across window / kernel resolution Swin Transformer V2Swin Transformer简介Scaling Up Mod…
当打开一个网页感觉很好奇,他使用了什么框架和什么技术?
常用的网页技术分析网站。
1. w3techs
Check web technologies used by a website - Site InfoW3Techs identifies which web technologies such as CMS, programming language, web server an…
“0”数字字符零 的图片(16*16点阵): import torch
import torch.nn as nn
import torch.optim as optim
from PIL import Image, ImageDraw, ImageFont
from torchvision import transforms
import matplotlib.pyplot as pltTimes20001000# 参数设置
font_path &q…