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

本站现有博文309篇,共被浏览732797

本站已经建立2370天!

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