莱特码CLI

leetcode-cli的Python项目详细描述


leetcode cli

开始tmuxvimleetcode-cli。尽可能多地练习下列问题:—)

此工具不属于LeetCode

安装

Mac OS X

brew install node
sudo easy_install leetcode-cli

Linux

sudo apt install nodejs
sudo pip install leetcode-cli

用法

最常见的命令是:cdlspullcatcheckpushcheatclear/

$ leetcode-cli

Username: student
Password:
Welcome student!
 (\_/)
=(^.^)=
(")_(")
243 solved 17 failed 523 todo

#:/> ?
cat                     - Show test case(s).
cd      <tag|number>    - Change problem(s).
cheat   <number>        - C.H.E.A.T.
check                   - Test the solution.
chmod   <language>      - Change programming language.
clear                   - Clear screen.
find    <keyword>       - Find problems by keyword. Alias: /<keyword>.
limit   <number>        - Limit the number of problems.
login                   - Login into the online judge.
ls                      - Show problem(s).
print   [keyword]       - Print problems by keyword in HTML.
pull    [*]             - Pull latest solution(s). '*': all problems.
push                    - Submit the solution.
su      <session>       - Change session.

A tag can refer to a topic (e.g. array) or a company (e.g. amazon).
A keyword can be anything (including a tag).
Commands and options can be completed via <TAB>.

#:/>

控制+D退出。

演示

在根(/)级别。ls列出所有主题。#用于没有主题的问题。

#:/> ls
     29 #
     81 array
     28 backtracking            <- 28 problems todo in backtracking
      5 binary-indexed-tree
     35 binary-search
     12 binary-search-tree
     26 bit-manipulation
      3 brainteaser
     31 breadth-first-search
     60 depth-first-search
...
     13 sort
     14 stack
     62 string
      3 topological-sort
     53 tree
     12 trie
     21 two-pointers
      9 union-find
242 solved 18 failed 523 todo

cd <topic>更改当前主题。

#:/> cd heap
#:/heap>

在主题层面,ls按难度和接受率列出问题。水平线用空行隔开。在每一个层次上,问题都按照接受率的顺序列出。 标记:*表示todoxfailed,无表示solved

#:/heap> ls
     355 design-twitter                             <- the hardest
    *719 find-k-th-smallest-pair-distance
    *836 race-car
      23 merge-k-sorted-lists
    *218 the-skyline-problem
    *803 cheapest-flights-within-k-stops

     295 find-median-from-data-stream               <- medium level
    *895 shortest-path-to-get-all-keys
     373 find-k-pairs-with-smallest-sums
...
     215 kth-largest-element-in-an-array
    *692 top-k-frequent-words
    *794 swim-in-rising-water

     378 kth-smallest-element-in-a-sorted-matrix    <- easy level
     347 top-k-frequent-elements
     451 sort-characters-by-frequency
    *761 employee-free-time                         <- the easiest
11 solved 0 failed 17 todo

cd <number>更改当前问题。然后ls显示描述。

#:/heap> cd 23
#:/heap/23-merge-k-sorted-lists> ls
[Linked-List, Heap, Divide-And-Conquer, 8/20]

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
Example:

Input:
[
 1->4->5,
 1->3->4,
 2->6
]
Output: 1->1->2->3->4->4->5->6

pull从在线法官处下载最新的解决方案和示例测试用例。如果没有提交解决方案,则使用锅炉板。解决方案/样板文件保存在./ws/<number>.<ext>中,并且可以编辑。

#:/heap/23-merge-k-sorted-lists> pull
,___,
[O.o]  Replace working copy? (y/N)
/)__)
-"--"-y
ws/23.py

cat显示示例测试用例。它保存在./ws/tests.dat中。测试用例可以添加到其中并由check使用。

#:/heap/23-merge-k-sorted-lists> cat
ws/23.py << [[1,4,5],[1,3,4],[2,6]]

现在我们有了问题描述和示例测试用例,开始编写代码并在本地测试解决方案。

$ vim ./ws/23.py
$ python ./ws/23.py

默认编程语言是Python。要更改它,请使用chmod <language>。一旦解决方案在本地通过了测试,我们就可以用它或者把它交给在线评审。push报告运行时和通过的测试数。

#:/heap/23-merge-k-sorted-lists> check
Input:  [[1,4,5],[1,3,4],[2,6]]
Result: [1,1,2,3,4,4,5,6]
Runtime: 20 ms

#:/heap/23-merge-k-sorted-lists> push
Runtime                                                                  %  ms
###############################################################################
**                                                                       0  48
*****                                                                    1  52
*****************                                                        2  56
**********************************************************************   8  60
***********************************************************************  8  64*
****************************************                                 5  68
***********************************************                          6  72
***************************************************************          7  76
**************************************                                   4  80
************************                                                 3  84
****************                                                         2  88
**************                                                           2  92
************                                                             1  96
****************                                                         2  100
*****************                                                        2  104
****************                                                         2  108
***********************                                                  3  112
********************************                                         4  116
************************                                                 3  120
***********************                                                  3  124
***********************                                                  3  128
******************                                                       2  132
**********                                                               1  136
*********                                                                1  140
Rank: 20.51%
Result: 131/131 tests passed
Runtime: 64 ms

/<keyword>搜索匹配标记(airbnb)或关键字(例如palindrome)的问题

#:/heap/23-merge-k-sorted-lists> cd ..
#:/heap> cd ..
#:/> /airbnb
     220 contains-duplicate-iii
      68 text-justification
      10 regular-expression-matching
    x212 word-search-ii
     269 alien-dictionary
    *336 palindrome-pairs
       2 add-two-numbers
      23 merge-k-sorted-lists
    *190 reverse-bits
    *803 cheapest-flights-within-k-stops

     227 basic-calculator-ii
     160 intersection-of-two-linked-lists
    *221 maximal-square
     385 mini-parser
     219 contains-duplicate-ii
      20 valid-parentheses
    *756 pour-water
      42 trapping-rain-water
       1 two-sum
     198 house-robber
     251 flatten-2d-vector
     415 add-strings
     202 happy-number

     108 convert-sorted-array-to-binary-search-tree
    *787 sliding-puzzle
    *757 pyramid-transition-matrix
     217 contains-duplicate
    *752 ip-to-cidr
    *761 employee-free-time
     136 single-number
20 solved 1 failed 9 todo

#:/>

解决方案保存在./ws/目录中。

print生成突出显示的语法HTML

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
graph Java:Dijkstra算法使用随机边更改边数   安卓中用java创建sqlite3表   如何将Char'S设置为$80 Java   java如何使用Htmlunit中的表单数据登录站点   java访问被拒绝尝试在windows 7 64位中运行eclipse helios时出错   线程的java调用层次结构。Eclipse中的run()   类如何在Java中从ArrayList绘制对象   java单例Servlet实例   java当我的电脑刚刚安装了x64 jdk7时,如何用x86 jdk构建代码   增量Java增量编号   java Lambda表达式不工作,正在终止   java侦听器和适配器之间有什么区别?   java设置变量,用于从被调用对象调用对象   java Spring安全4:提供角色时拒绝访问