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

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

本站已经建立2617天!

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