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

本站现有博文312篇,共被浏览744673

本站已经建立2388天!

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