npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ts-leetcode

v0.3.4

Published

背景和开发过程见此[博文](https://qszhu.github.io/2020/08/16/leetcode-with-typescript.html)

Downloads

12

Readme

背景和开发过程见此博文

LeetCode TypeScript 解题工具

特性

  • 针对leetcode-cn.com开发
  • 提供TypeScript工程模版,支持自定义
  • 使用本地测试数据
  • 支持同一个问题的多个解答,可随时切换

运行需求

  • Node.js v10+
  • Google Chrome
  • 仅在Mac OSX下测试过

安装

$ npm i -g ts-leetcode

初始化工程

$ npm i
$ mv .tslcrc.example .tslcrc
  • 根据需要调整.tslcrcbrowserPath的值为Google Chrome浏览器路径

  • 登录(用户名和密码会被直接发送到leetcode网站,不会被保存到本地或其他地方):

$ tslc login
✔ Username: · xxxxxxxx
✔ Password: · ********
Logging in, this may take some time...
Success!

解题步骤

  1. 创建解答目录
$ tslc init invert-binary-tree

需提供题目的短标题作为参数。例如题目的url为https://leetcode-cn.com/problems/invert-binary-tree/,则题目的短标题为url路径的最后一部分invert-binary-tree

若第一次运行,此命令会创建如下目录结构:

questions/invert-binary-tree
├── input
├── solution.ts -> solution1.ts
├── solution1.ts
└── tsconfig.json
  1. 编辑input中的测试数据

  2. 编辑solution.ts中的代码

  3. 编译

$ tslc build
Hash: f5834e34f10e512f08a5
Version: webpack 4.44.1
Time: 1235ms
Built at: 2020-08-15 11:46:53 AM
      Asset      Size  Chunks             Chunk Names
solution.js  7.03 KiB       0  [emitted]  main
Entrypoint main = solution.js
[0] ./questions/invert-binary-tree/solution1.ts 868 bytes {0} [built]
  1. 测试
$ tslc test
STARTED
STARTED
SUCCESS
  1. 提交
$ tslc submit
STARTED
Accepted
Runtime: 84 ms, 32.27%
Memory: 40 MB, 5.12%

配置.tslcrc

备注

  • tslc init可以被多次运行,每次运行会新增一个解答文件
    • 新文件按照solution2.ts, solution3.ts的顺序命名
    • solution.ts是指向最新解答文件的软链接,是后续构建测试和提交的输入文件
    • tslc select <n> [questionSlug]会将软链接指向solution<n>.ts
  • 如果未向命令行提供题目短标题,则会使用最近一次命令中使用过的短标题