【VS Code】安装 LeetCode 插件
练习算法绕不开的一个网站就是力扣,很多小伙伴为了拿到大厂 offer,刷题都刷到吐了。
然而如果直接在 LeetCode 上写代码,那是很痛苦的一件事,那就相当于用 txt 写代码一样,没有 IDE 的各种功能。
VS Code 的 LeetCode 插件帮助我们解决了这一问题。以下是官方教程:https://github.com/jdneo/vscode-leetcode/blob/master/docs/README_zh-CN.md。
其实这个教程已经很详细了,我只是在个别地方做了补充。
安装 LeetCode 插件
首先需要安装的是 Node.JS,因为 LeetCode 插件依赖 Node.JS。Node.JS 官网地址:https://nodejs.org/en/
Node.JS 的安装很简单,一直下一步就可以了。要注意的是,必须将 Node.JS 安装目录添加到环境变量,现在的安装版本默认就是添加的,如果没有,则手动添加一下。
其次在 VS Code 中搜索并安装 LeetCode 插件。

安装完成之后,左边会出现一个 LeetCode 图标,见下图:

登录 LeetCode
点击【LeetCode】图标,然后点击登录 LeetCode 账户。

然后你很可能就登录失败了。报 invalid password
,你以为是密码输错了,然后就重试了一遍又一遍,结果还是不行。崩溃!!!
LeetCode 目前有英文版(leetcode.com)和中文版(leetcode-cn.com)两种版本。点击

答题
选择你要做的题目,右键

- 点击【Preview Problem】可以查看题目描述
- 点击【Show Problem】可进行答题。
答题前需要先选择语言:

选择语言之后,需要选择一个 workspace。官方文档中说,需要更新配置项 leetcode.workspaceFolder
,但是,如果你用的是最新版的 VS Code,就没那么麻烦了。我不得不说,最新版的 VS Code 配置上改变得很好了,以前的配置,如果你不习惯的话,那就是反人类的。新版的配置变得非常的简单了,点点就好。

最后,写完之后可以点击代码下面的【Test】按钮测试,或是【Submit】按钮提交。

结果在右侧显示:

· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· .NET 10 首个预览版发布,跨平台开发与性能全面提升
· 全程使用 AI 从 0 到 1 写了个小工具
· 快收藏!一个技巧从此不再搞混缓存穿透和缓存击穿
· AI 插件第二弹,更强更好用
· Blazor Hybrid适配到HarmonyOS系统