All Projects → clearloop → leetcode-cli

clearloop / leetcode-cli

Licence: MIT license
May the code be with you 👻

Programming Languages

rust
11053 projects
Nix
1067 projects
shell
77523 projects

Projects that are alternatives of or similar to leetcode-cli

Data-Structure-Algorithms-LLD-HLD
A Data Structure Algorithms Low Level Design and High Level Design collection of resources.
Stars: ✭ 922 (+420.9%)
Mutual labels:  leetcode
SoleilNotes
技术面试必备知识点:Android、Java、C、C++、Python、Flutter、Gradle、数据结构、计算机组成原理、计算机网络、操作系统、算法、数据结构、设计模式、密码学等等
Stars: ✭ 483 (+172.88%)
Mutual labels:  leetcode
swift-leetcode
记录自己使用swift刷LeetCode的代码
Stars: ✭ 17 (-90.4%)
Mutual labels:  leetcode
algo
🧠 Algorithms and Data structures
Stars: ✭ 17 (-90.4%)
Mutual labels:  leetcode
CVIP
C/C++/Golang/Linux...知识整理
Stars: ✭ 62 (-64.97%)
Mutual labels:  leetcode
leetcode
📊My Leetcode environment for JavaScript and Rust
Stars: ✭ 42 (-76.27%)
Mutual labels:  leetcode
LeetCode
LeetCode Problems
Stars: ✭ 41 (-76.84%)
Mutual labels:  leetcode
Coding-Interviews
Repository with resources to prepare for coding interviews
Stars: ✭ 46 (-74.01%)
Mutual labels:  leetcode
The-Complete-FAANG-Preparation
This repository contains all the DSA (Data-Structures, Algorithms, 450 DSA by Love Babbar Bhaiya, FAANG Questions), Technical Subjects (OS + DBMS + SQL + CN + OOPs) Theory+Questions, FAANG Interview questions, and Miscellaneous Stuff (Programming MCQs, Puzzles, Aptitude, Reasoning). The Programming languages used for demonstration are C++, Pytho…
Stars: ✭ 8,681 (+4804.52%)
Mutual labels:  leetcode
Coding-Practice
Coding practice, design pattern implementation in C++ and some knowledge summary.
Stars: ✭ 48 (-72.88%)
Mutual labels:  leetcode
DataStructure-DesignPattern
java集合源码、设计模式、常用算法、Mysql原理
Stars: ✭ 22 (-87.57%)
Mutual labels:  leetcode
LeetCode
solve some problems on LeetCode
Stars: ✭ 25 (-85.88%)
Mutual labels:  leetcode
Competetive programming
Contains my solutions to thousands of different CP sums and some DSA Problems(available in snippets)
Stars: ✭ 21 (-88.14%)
Mutual labels:  leetcode
GolangStudy
《golang 面试学习》:从简单到难最全总结,go基础,数据结构,算法,设计模式。B站/抖音关注:程序猿Go师傅,跟着视频学习。
Stars: ✭ 148 (-16.38%)
Mutual labels:  leetcode
cs-interview-questions
Personal Solutions to Interview Questions
Stars: ✭ 59 (-66.67%)
Mutual labels:  leetcode
algorithm
Leetcode/剑指offer/经典算法题型
Stars: ✭ 69 (-61.02%)
Mutual labels:  leetcode
Dynamic-Programming-Questions-by-Aditya-Verma
Aditya Verma (Youtube) DP Playlist Codes/Solutions.
Stars: ✭ 148 (-16.38%)
Mutual labels:  leetcode
python-cp-cheatsheet
Python3 interview prep cheatsheet and examples
Stars: ✭ 407 (+129.94%)
Mutual labels:  leetcode
cv
Rust CV mono-repo. Contains pure-Rust dependencies which attempt to encapsulate the capability of OpenCV, OpenMVG, and vSLAM frameworks in a cohesive set of APIs.
Stars: ✭ 426 (+140.68%)
Mutual labels:  crates
Data-Structures-and-Algorithms
Most frequent LeetCode questions to ace the coding interview!
Stars: ✭ 67 (-62.15%)
Mutual labels:  leetcode

leetcode-cli

Rust crate doc downloads gitter LICENSE

Installing

# Required dependencies:
# 
#  gcc
#  libssl-dev
#  libdbus-1-dev
#  libsqlite3-dev

cargo install leetcode-cli

Usage

Make sure you have logged in to leetcode.com with Chrome. See Cookies for why you need to do this first.

leetcode 0.3.10
May the Code be with You 👻

USAGE:
    leetcode [FLAGS] [SUBCOMMAND]

FLAGS:
    -d, --debug      debug mode
    -h, --help       Prints help information
    -V, --version    Prints version information

SUBCOMMANDS:
    data    Manage Cache [aliases: d]
    edit    Edit question by id [aliases: e]
    exec    Submit solution [aliases: x]
    list    List problems [aliases: l]
    pick    Pick a problem [aliases: p]
    stat    Show simple chart about submissions [aliases: s]
    test    Edit question by id [aliases: t]
    help    Prints this message or the help of the given subcommand(s)

Example

For example, given this config (can be found in ~/.leetcode/leetcode.toml, it can be generated automatically with command: leetcode list if you are a new user):

[code]
lang = "rust"
editor = "emacs"

1. pick

leetcode pick 1
[1] Two Sum is on the run...


Given an array of integers, return indices of the two numbers such that they add up to a specific target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

--------------------------------------------------

Example:


Given nums = [2, 7, 11, 15], target = 9,

Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].

2. edit

leetcode edit 1
# struct Solution;
impl Solution {
    pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
        use std::collections::HashMap;
        let mut m: HashMap<i32, i32> = HashMap::new();

        for (i, e) in nums.iter().enumerate() {
            if let Some(v) = m.get(&(target - e)) {
                return vec![*v, i as i32];
            }

            m.insert(*e, i as i32).unwrap_or_default();
        }

        return vec![];
    }
}

3. test

leetcode test 1
  Accepted       Runtime: 0 ms

  Your input:    [2,7,11,15], 9
  Output:        [0,1]
  Expected:      [0,1]

4. exec

leetcode exec 1
  Success

  Runtime: 0 ms, faster than 100% of Rustonline submissions for Two Sum.

  Memory Usage: 2.4 MB, less than 100% of Rustonline submissions for Two Sum.

Cookies

The cookie plugin of leetcode-cli can work on OSX and Linux. If you are on a different platform, there are problems with caching the cookies, you can manually input your LeetCode Cookies to the configuration file.

[cookies]
csrf = "..."
session = "..."

For Example, using Chrome (after logging in to LeetCode):

Step 1

Open Chrome and navigate to the link below:

chrome://settings/cookies/detail?site=leetcode.com

Step 2

Copy Content from LEETCODE_SESSION and csrftoken to session and csrf in your configuration file, respectively:

[cookies]
csrf = "${csrftoken}"
session = "${LEETCODE_SESSION}"

Programmable

If you want to filter LeetCode questions using custom Python scripts, add the following to your the configuration file:

[storage]
scripts = "scripts"

Then write the script:

# ~/.leetcode/scripts/plan1.py
import json;

def plan(sps, stags):
    ##
    # `print` in python is supported, 
    # if you want to know the data structures of these two args, 
    # just print them
    ##
    problems = json.loads(sps)
    tags = json.loads(stags)
	
    ret = []
    tm = {}
    for tag in tags:
        tm[tag["tag"]] = tag["refs"];

    for i in problems:
        if i["level"] == 1 and str(i["id"]) in tm["linked-list"]:
            ret.append(str(i["id"]))

    # return is `List[string]`
    return ret

Then run list with the filter that you just wrote:

leetcode list -p plan1

And that's it! Enjoy!

PR

PRs are more than welcome!

LICENSE

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].