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

本站现有博文322篇,共被浏览784685

本站已经建立2478天!

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