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

本站现有博文319篇,共被浏览752993

本站已经建立2410天!

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