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

本站现有博文321篇,共被浏览780374

本站已经建立2473天!

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