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

本站现有博文333篇,共被浏览922046

本站已经建立2628天!

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