Git Product home page Git Product logo

vscode-leetcode's Introduction

LeetCode

Solve LeetCode problems in VS Code

❗️ Attention ❗️- Workaround to login to LeetCode endpoint

Note: If you are using leetcode.cn, you can just ignore this section.

Recently we observed that the extension cannot login to leetcode.com endpoint anymore. The root cause of this issue is that leetcode.com changed its login mechanism and so far there is no ideal way to fix that issue.

Thanks for @yihong0618 provided a workaround which can somehow mitigate this. Now you can simply click the Sign In button and then select Third Party login or Cookie login.

Note: If you want to use third-party login(Recommended), please make sure your account has been connected to the third-party. If you want to use Cookie login, click here to see the steps.

Requirements

  • VS Code 1.30.1+
  • Node.js 10+

    NOTE: Please make sure that Node is in your PATH environment variable. You can also use the setting leetcode.nodePath to specify the location of your Node.js executable.

Quick Start

demo

Features

Sign In/Out

Sign in

  • Simply click Sign in to LeetCode in the LeetCode Explorer will let you sign in with your LeetCode account.

  • You can also use the following command to sign in/out:

    • LeetCode: Sign in
    • LeetCode: Sign out

Switch Endpoint

Switch Endpoint

  • By clicking the button btn_endpoint at the explorer's navigation bar, you can switch between different endpoints.

  • The supported endpoints are:

    • leetcode.com
    • leetcode.cn

    Note: The accounts of different endpoints are not shared. Please make sure you are using the right endpoint. The extension will use leetcode.com by default.


Pick a Problem

Pick a Problem

  • Directly click on the problem or right click the problem in the LeetCode Explorer and select Preview Problem to see the problem description.

  • Select Show Problem to directly open the file with the problem description.

    Note:You can specify the path of the workspace folder to store the problem files by updating the setting leetcode.workspaceFolder. The default value is:$HOME/.leetcode/.

    You can specify whether including the problem description in comments or not by updating the setting leetcode.showCommentDescription.

    You can switch the default language by triggering the command: LeetCode: Switch Default Language.


Editor Shortcuts

Editor Shortcuts

  • The extension supports 5 editor shortcuts (aka Code Lens):

    • Submit: Submit your answer to LeetCode.
    • Test: Test your answer with customized test cases.
    • Star/Unstar: Star or unstar the current problem.
    • Solution: Show the top voted solution for the current problem.
    • Description: Show the problem description page.

    Note: You can customize the shortcuts using the setting: leetcode.editor.shortcuts. By default, only Submit and Test shortcuts are enabled.


Search problems by Keywords

Search problems by Keywords

  • By clicking the button btn_search at the explorer's navigation bar, you can search the problems by keywords.

Manage Session

Manage Session

  • To manage your LeetCode sessions, just clicking the LeetCode: *** at the bottom of the status bar. You can switch between sessions or create, delete a session.

Settings

Setting Name Description Default Value
leetcode.hideSolved Specify to hide the solved problems or not false
leetcode.showLocked Specify to show the locked problems or not. Only Premium users could open the locked problems false
leetcode.defaultLanguage Specify the default language used to solve the problem. Supported languages are: bash, c, cpp, csharp, golang, java, javascript, kotlin, mysql, php, python,python3,ruby,rust, scala, swift, typescript N/A
leetcode.useWsl Specify whether to use WSL or not false
leetcode.endpoint Specify the active endpoint. Supported endpoints are: leetcode, leetcode-cn leetcode
leetcode.workspaceFolder Specify the path of the workspace folder to store the problem files. ""
leetcode.filePath Specify the relative path under the workspace and the file name to save the problem files. More details can be found here.
leetcode.enableStatusBar Specify whether the LeetCode status bar will be shown or not. true
leetcode.editor.shortcuts Specify the customized shortcuts in editors. Supported values are: submit, test, star, solution and description. ["submit, test"]
leetcode.enableSideMode Specify whether preview, solution and submission tab should be grouped into the second editor column when solving a problem. true
leetcode.nodePath Specify the Node.js executable path. for example, C:\Program Files\nodejs\node.exe node
leetcode.showCommentDescription Specify whether to include the problem description in the comments false
leetcode.useEndpointTranslation Use endpoint's translation (if available) true
leetcode.colorizeProblems Add difficulty badge and colorize problems files in explorer tree true
leetcode.problems.sortStrategy Specify sorting strategy for problems list None

Want Help?

When you meet any problem, you can check out the Troubleshooting and FAQ first.

If your problem still cannot be addressed, feel free to reach us in the Gitter Channel or file an issue.

Release Notes

Refer to CHANGELOG

Acknowledgement

vscode-leetcode's People

Contributors

anshkathuria avatar dependabot[bot] avatar dzz007 avatar edvardchen avatar fuafa avatar himself65 avatar hologerry avatar houtianze avatar ifun avatar jdneo avatar lnkleo avatar magic-akari avatar miloas avatar nathanesau avatar ntt2k avatar poppinlp avatar pujiaxun avatar purocean avatar ringcrl avatar sf-zhou avatar tejasvi avatar tsfreddie avatar vigilans avatar xeonacid avatar xuzaixian avatar yihong0618 avatar zainchen avatar zry656565 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-leetcode's Issues

login username issue

I'm allowed to sign in with holybasil rather than Holybasil while my username of LeetCode is Holybasil

failed to load locked problem! [0]

failed to load locked problem! [0]
when even I have signed in a premium account
was searching/click question:
Two Sum III - Data structure design

Login issue

Hi ,
I got "socket hang up" error when I login. Any idea how to avoid this?

thanks

all problems occur twice in list

image

e.g. in above image, Hard = [4, 10, 23, ..., 782, 786, 4, 10, 23, ..., 782, 786]
Tried signing out and in again, it's the same result.

Support leetcode-cn

LeetCode ** is the Chinese version of LeetCode. It provides a more comfortable experience for Chinese users, I think.

However, data of the universal version and the Chinese version of LeetCode is not shared. If we want, we have to sync them manually. So can we choose which version to use? 😃

Thanks!

BTW, I have learned that this extension is based on the leetcode-cli project. Maybe I had better open an issue there...

login issue

I got the issue blow.
SyntaxError: Unexpected end of input
at Object.parse (native)
at Object.cache.get (C:\Users\afu.vscode\extensions\shengchen.vscode-leetcode-0.6.1\node_modules\leetcode-cli\lib\cache.js:17:15)
at Function.__dirname.Plugin.deps.deps.Plugin.init.plugins [as init] (C:\Users\afu.vscode\extensions\shengchen.vscode-leetcode-0.6.1\node_modules\leetcode-cli\lib\plugin.js:131:22)
at Object.cli.run (C:\Users\afu.vscode\extensions\shengchen.vscode-leetcode-0.6.1\node_modules\leetcode-cli\lib\cli.js:82:14)
at Object. (C:\Users\afu.vscode\extensions\shengchen.vscode-leetcode-0.6.1\node_modules\leetcode-cli\bin\leetcode:3:23)
at Module._compile (module.js:397:26)
at Object.Module._extensions..js (module.js:404:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:429:10)
[ERROR] You are not login yet? [0]
login: login: pass: login: pass:

Session expired problem

Hi, here is the bug

If I login leetcode.com by vscode, and login on chrome same time.
It will show the session expired problem.

2018-02-20 3 44 58

登录不上

/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:2844 [shengchen.vscode-leetcode]This socket has been ended by the other party

/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:2844 Error: This socket has been ended by the other party
at Socket.writeAfterFIN [as write] (net.js:305:12)

[登陆问题] TypeError: Cannot read property 'id_hash' of undefined

login: login: pass: [ERROR] invalid password? [0]
login: pass: /Users/xxx/.vscode/extensions/shengchen.vscode-leetcode-0.8.0/node_modules/leetcode-cli/lib/plugins/leetcode.js:466
    user.hash = favorite.id_hash;
                         ^

TypeError: Cannot read property 'id_hash' of undefined
    at /Users/xxx/.vscode/extensions/shengchen.vscode-leetcode-0.8.0/node_modules/leetcode-cli/lib/plugins/leetcode.js:466:26
    at Request._callback (/Users/xxx/.vscode/extensions/shengchen.vscode-leetcode-0.8.0/node_modules/leetcode-cli/lib/plugins/leetcode.js:381:12)
    at Request.self.callback (/Users/xxx/.vscode/extensions/shengchen.vscode-leetcode-0.8.0/node_modules/request/request.js:186:22)
    at Request.emit (events.js:182:13)
    at Request.<anonymous> (/Users/xxx/.vscode/extensions/shengchen.vscode-leetcode-0.8.0/node_modules/request/request.js:1163:10)
    at Request.emit (events.js:182:13)
    at IncomingMessage.<anonymous> (/Users/xxx/.vscode/extensions/shengchen.vscode-leetcode-0.8.0/node_modules/request/request.js:1085:12)
    at Object.onceWrapper (events.js:273:13)
    at IncomingMessage.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1085:12)

SyntaxError: Unexpected string in JSON at position 27

I can't log in.
need your help.
v8.12.0
undefined:1
{"cache":true,"retry":true}"leetcode.cn":true}
^

SyntaxError: Unexpected string in JSON at position 27
at JSON.parse ()
at Object.cache.get (C:\Users\oyx.vscode\extensions\shengchen.vscode-leetcode-0.8.0\node_modules\leetcode-cli\lib\cache.js:17:15)
at Function.Plugin.init (C:\Users\oyx.vscode\extensions\shengchen.vscode-leetcode-0.8.0\node_modules\leetcode-cli\lib\plugin.js:131:22)
at Object.cli.run (C:\Users\oyx.vscode\extensions\shengchen.vscode-leetcode-0.8.0\node_modules\leetcode-cli\lib\cli.js:82:14)
at Object. (C:\Users\oyx.vscode\extensions\shengchen.vscode-leetcode-0.8.0\node_modules\leetcode-cli\bin\leetcode:3:23)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)

__

Installed Node.js doesn't work

I typed node -v and got v6.7.0 and then in VS Code, the error message shows Command 'leetcode.refreshExplorer' not found.
screen shot 2018-02-19 at 9 44 24 pm

unexpected syntax errors

When I open a problem in C++, it cannot identify vector, unordered_map...
In this way, I have to include all all I need in this program,e.g. #include
Although it can succeed to submit to leetcode, it is a little troublesome...
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.