EADST

LeetCode: Quickly setup the Python List

Recently, I have done lots of LeetCode problems. Here are some quick shortcuts to change the list.

# initial one-dimensional array with length N
Array = [0] * N

# initial two-dimensional array with M*N
Matrix = [[0] * N for _ in range(M)]

# reverse the list [0, 1, 2]->[2, 1, 0]
new_list = old_list[::-1]
new_list = old_list.reverse()

# pop out the element in the list [0, 1, 2]->[0, 2]
new_list = old_list.pop(1)

# insert the element in the list [0, 1, 2]->[0, "s", 1, 2]
new_list = old_list.insert(1, "s")

# For a four-direction traversal, create an array [-1, 0, 1, 0, -1], each of which is one of the four directions.

相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
CAM Rebuttal Clash Search 算法题 Google GPTQ WebCrawler Video Streamlit Interview hf Pytorch Bin Anaconda Password 关于博主 SVR Git FP64 Tensor TTS PyCharm UNIX Template 证件照 Land 腾讯云 JSON Conda 继承 icon Django Agent LLM 签证 Distillation v2ray Magnet tqdm HuggingFace Bipartite XGBoost FP32 Zip VPN FlashAttention Mixtral Jetson Jupyter Linux Cloudreve CC 域名 YOLO Augmentation TSV 财报 LLAMA Qwen2.5 Shortcut Data 图标 Diagram Paper Color Firewall 公式 Hotel 递归学习法 Attention Pandas uwsgi CLAP Pillow LeetCode 强化学习 SPIE uWSGI DeepStream 云服务器 QWEN Miniforge FP16 XML diffusers BTC TensorRT FP8 搞笑 Ubuntu Image2Text GIT ModelScope 净利润 多进程 TensorFlow Nginx Michelin Python logger Transformers Website Hungarian 论文速读 GPT4 WAN Statistics LaTeX Dataset ChatGPT Disk Qwen Sklearn v0.dev Quantize 音频 SQL 报税 Markdown BF16 llama.cpp 顶会 API Translation OpenAI RGB GGML C++ BeautifulSoup CUDA Tiktoken CTC MD5 Vim OpenCV scipy Safetensors Card RAR Permission PIP GoogLeNet AI Algorithm Logo IndexTTS2 Bitcoin 飞书 Claude Datetime Food git-lfs InvalidArgumentError Math ONNX Crawler Web Breakpoint torchinfo Proxy Random COCO CEIR VGG-16 PDB Review SAM NLTK NLP Heatmap git Vmess News 多线程 PyTorch Plate Pickle PDF 图形思考法 Domain 版权 Qwen2 Windows Freesound Excel Github 第一性原理 阿里云 LoRA Knowledge tar Docker ResNet-50 NameSilo Ptyhon Tracking FastAPI printf EXCEL Quantization Baidu SQLite Input Animate mmap CV Plotly 论文 Hilton Paddle OCR Bert HaggingFace Llama Numpy transformers VSCode Gemma Use UI CSV Base64 DeepSeek
站点统计

本站现有博文327篇,共被浏览833105

本站已经建立2538天!

热门文章
文章归档
回到顶部