使用VSCode刷LeetCode

使用VS Code刷LeetCode

一、前言

1.1、说明

本文章用来记录使用VS Code刷LeetCode中遇到的一系列问题。

1.2、原因

  • leetcode 网站中的在线编程环境代码提示、快捷键不友好

  • VS Code中可以通过插件同步Leetcode所有题目,并且在VS Code中进行查看、测试、提交。

  • ......

1.2、参考文章

二、具体操作

2.1、VS Code中初始化刷题环境

首先确保已经安装node.js,通过通过如下命令查看安装情况,具体安装过程可以自行搜索,这里推荐使用nvm(nodejs的版本管理工具)去安装和管理node.js和对应的npm(Node.js 的官方包管理工具):nvm下载教程

在VS Code中搜索LeetCode的插件,并安装

!外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(https://img-home.csdnimg.cn/images/202![在这里插入图片描述](https://file.jishuzhan.net/article/1789842211228094466/f941448cddfe4f822ff17d10b1a072af.webp)

安装完成后,在VS Code界面的左侧会出现一个LeetCode的图标

点击Sign in to LeetCode,并选择用LeetCode的账号登录

输入账号和密码

如果提示如下内容,是因为Node14以下版本的NodeJS项目在Node14及以上版本中运行时所抛出的异常

复制代码
login: (node:40124) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
pass: - Signing in leetcode.com
[ERROR] session expired, please login again [code=-1]

我们通过nvm切换较低的node版本,nvm相关命令可以参考这篇文章(最下面):https://blog.csdn.net/Bananaaay/article/details/131738477

此时提示的内容是,可以发现不报错了

复制代码
login: pass: - Signing in leetcode.com
[ERROR] session expired, please login again [code=-1]

我们将leetcode切换到中国版本

之后再按上面的登录流程,即可登录成功

此时,我们可以在VS CODE左侧看到刷题的内容

之后就可以开始刷题了

相关推荐
蛋蛋的就会顺顺的11 小时前
hot100——矩阵
java·数据结构·算法·leetcode·力扣
想吃火锅100515 小时前
【leetcode】238.除了自身以外数组的乘积js
javascript·算法·leetcode
Tisfy17 小时前
LeetCode 0020.有效的括号:栈匹配
算法·leetcode·字符串·题解·括号匹配
oooost17 小时前
Jupyter Notebook 常用快捷键速查
ide·python·jupyter
Navigator_Z17 小时前
LeetCode //C - 1276. Number of Burgers with No Waste of Ingredients
c语言·算法·leetcode
想吃火锅100518 小时前
【leetcode】189.轮转数组js
开发语言·javascript·leetcode
All for pursuit.19 小时前
【贪心-2】253.会议室 II
数据结构·c++·算法·leetcode
承渊政道20 小时前
Linux系统学习【线程概念与控制核心知识详解】
linux·运维·vscode·学习·ubuntu·线程创建 终止 等待
yqj2341 天前
ESP32-S3中小智项目优化内容
ide·macos·xcode
阿斌.com1 天前
Visual Studio 2026安装全攻略
ide·visual studio