使用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左侧看到刷题的内容

之后就可以开始刷题了

相关推荐
Dream it possible!9 小时前
LeetCode 面试经典 150_链表_旋转链表(64_61_C++_中等)
c++·leetcode·链表·面试
坚持编程的菜鸟11 小时前
LeetCode每日一题——Pow(x, n)
c语言·算法·leetcode
C7211BA11 小时前
Visual Studio Code (VS Code) 官方下载渠道
ide·vscode·编辑器
zhangfeng113311 小时前
win7 VSCode 1.70设置R语言的版本,电脑上有两个版本
ide·vscode·r语言
学习和思考11 小时前
为什么我的vscode有的时候可以跳转,有的时候不能跳转
arm开发·ide·驱动开发·vscode·学习·1024程序员节
新手村领路人12 小时前
vscode ssh远程连接 ubuntu虚拟机
ide·vscode·ssh
小-黯12 小时前
VSCode + XMake搭建OpenGL开发环境
vscode·opengl·xmake
繁依Fanyi12 小时前
【参赛心得】我的 HarmonyOS 开发入门与参赛之路
ide·人工智能·华为·word·harmonyos·aiide·codebuddyide
Wenhao.13 小时前
LeetCode LRU缓存
算法·leetcode·缓存·golang
小白菜又菜13 小时前
Leetcode 2273. Find Resultant Array After Removing Anagrams
算法·leetcode·职场和发展