Giter Site home page Giter Site logo

leetcode-go's Introduction

Leetcode-go

Leetcode-go is a CLI written in golang for retrieval and submission of problems hosted on https://leetcode.com/. You can search problems, download them, run them against sample/your own testcases and submit them to your leetcode profile.

Installation

If you have golang installed, you can install the app using go install. Simply write this to in your terminal.

go install github.com/Manan-Prakash-Singh/leetcode-go@latest

Authentication

There is no need to insert your username and password. Just make sure you are logged in into your accout in your browser. It searches through your browser cookies and finds the csrftoken and LEETCODE_SESSION token. For now, this works for firefox and chrome on Linux. To test if you are authenticated, type

leetcode-go auth

Note : I still need to test it on MacOS and Windows.

Downloading problem

To download the problem, you can use leetcode-go problem "problem name in quotes" --lang cpp. This will download if it can find the problem in cpp. But this requires you to know the full name of thee problem, which can be cumbersome, therfore, you can use leetcode-go search "search term" instead to search for the problem and then it will automatically ask you to language that you need to download the problem in. The problem statement is downloaded in a problem.txt file whereas the code snippet is downloaded as your chosen language.

Submitting/Running your code

When you download the code using leetcode-go, it saves it in the form "longest-increasing-subsequence_300". This format is expected when the filename is parsed, so don't change this. Moreover, the sample test cases are written inside the program file, enclosed inside block comments /* */. Each test case is seperated by ;. You can add your own test cases in it but make sure to keep the block comment at the top of the file.

/*

[2,7,11,15]
9;

[3,2,4]
6;

[3,3]
6;

*/
class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        
    }
};

Note : The problem must be in the current directory.

For help, just type leetcode-go help

Leetcode-go is a simple cli that can search, download, and submit problems
on leetcode through the command line

Usage:
  leetcode-go [command]

Available Commands:
  auth        Authenticate user using cookies
  help        Help about any command
  problem     Download the problem in the current directory
  qod         Get problem of the day
  run         Run your code with the test cases in your program file.
  search      search a problem
  submit      Submit your code to leetcode
  topic       Get a list of problems of a particular topic

Flags:
  -h, --help   help for leetcode-go

Use "leetcode-go [command] --help" for more information about a command.

leetcode-go's People

Contributors

jsq1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

c0dehu1k

leetcode-go's Issues

Panic while searching problem with topic

~/github/leetcode-go main !1 ?8 ❯ leetcode-go topic linkedlist 15s 
▀ Fetcing linkedlist problems... (0s)panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x7e08dd]

goroutine 1 [running]:
github.com/Manan-Prakash-Singh/leetcode-go/core.GetTopics({0x7ffdafe130cc, 0xa})
/home/om/go/pkg/mod/github.com/!manan-!prakash-!singh/[email protected]/core/main.go:193 +0x17d
github.com/Manan-Prakash-Singh/leetcode-go/cmd.glob..func7(0xd3a5c0?, {0xc0000994d0?, 0x1?, 0x1?})
/home/om/go/pkg/mod/github.com/!manan-!prakash-!singh/[email protected]/cmd/topic.go:19 +0x2a
github.com/spf13/cobra.(*Command).execute(0xd3a5c0, {0xc0000994a0, 0x1, 0x1})
/home/om/go/pkg/mod/github.com/spf13/[email protected]/command.go:944 +0x847
github.com/spf13/cobra.(*Command).ExecuteC(0xd39a40)
/home/om/go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
/home/om/go/pkg/mod/github.com/spf13/[email protected]/command.go:992
github.com/Manan-Prakash-Singh/leetcode-go/cmd.Execute()
/home/om/go/pkg/mod/github.com/!manan-!prakash-!singh/[email protected]/cmd/root.go:30 +0x2e
main.main()
/home/om/go/pkg/mod/github.com/!manan-!prakash-!singh/[email protected]/main.go:9 +0x17

Noway to cancel the search/Download

search a problem
Mood changed, I don't wanna download it any more.

How can I cancel the current menu? Esc key should work.

Currently ctrl+c works.

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.