A leetcode workspace template with test case runner for JavaScript/TypeScript programmers.

Overview

leetcode-typescript-workspace

English | 简体中文

A vscode workspace template with test case runner script for JavaScript/TypeScript programmers using extension LeetCode.vscode-leetcode.

Features

  • TypeScript definitions for leetcode OJ's built-in data structures (maybe not all of them) 💡
  • TypeScript definitions for leetcode OJ's built-in libraries
  • JavaScript/TypeScript test runner & debugger configuration 🐞

Why not...

A vscode extension?

First it's a little bit difficult to contribute type definitions to TypeScript Language Service. It's easier to create a TypeScript project and add global declarations for TypeScript support instead. Second, it's complicated to debug TypeScript without JavaScript code and source map, so we do need code generation. Also, setting debug configuration takes a lot of time for users who are more concerned about solutions. A configured workspace is easier to use, out of the box.

An NPM package? 📦

It's a possible solution to publish an NPM package with executable test runner script and global TypeScript declarations. But users still need to configure the debugger if they want to debug the program by vscode's debug tool. Another reason is the library version may change at time. With a configured workspace, users can configure the current library versions by simply modifying the versions in package.json.

So it's a better choice to make a workspace template for better UX 🎉 .

Usage

0. Requirements

  • vscode latest
  • Node.JS >= 14.0.0

1. Clone this repository

# via HTTPS
git clone https://github.com/DarrenDanielDay/leetcode-typescript-workspace.git
# via SSH
git clone [email protected]:DarrenDanielDay/leetcode-typescript-workspace.git
# via GitHub CLI
gh repo clone DarrenDanielDay/leetcode-typescript-workspace

And then open this repository with vscode. If you see extension recommendation, please install it 👈 .

2. Install dependencies

You can install dependencies via npm, yarn, pnpm or any other Node.JS package manager you like.

# via npm
npm install
# via yarn
yarn install
# via pnpm
pnpm install

3. Write solution code

Supported built-in library:

Known global library variables:

var _; // lodash
var Queue; // @datastructures-js/priority-queue
class MaxPriorityQueue {} // @datastructures-js/priority-queue
class MinPriorityQueue {} // @datastructures-js/priority-queue
class PriorityQueue {} // @datastructures-js/priority-queue

Check the dependency versions in package.json. See global-libs.ts for injection details.

Supported leetcode's built-in data structure declaration & implementation:

  • ListNode
  • TreeNode
  • NestedInteger (nested list)

See global-builtins.ts for implementation details.

For how to create, write and submit your solution to leetcode with LeetCode.vscode-leetcode, see user guide.

4. Write test cases

LeetCode.vscode-leetcode will not submit code below comment // @lc code=end to leetcode, so you can write test code there.

You can write test code with the following global test utility API:

  • test.Func: test function
  • test.Class: test class
  • test.list: utilities for ListNode
  • test.tree: utilities for TreeNode
  • test.nested: utilities for NestedInteger

But REMEMBER NOT TO USE THESE API IN YOUR SOLUTION CODE! They will not work correctly on leetcode OJ!

See following demo solution files for more API usage details.

5. Run/Debug

Run directly:

# via npm
npm run lc:run ./<solution-file.js>
# via yarn
yarn lc:run ./<solution-file.js>
# via pnpm
pnpm lc:run ./<solution-file.js>

where <solution-file.js> is your solution file created by LeetCode.vscode-leetcode.

Debug with vscode:

You can add breakpoints in your solution files. Just press F5 when you cursor is currently focusing on a solution file to start a debug session.

TODO

Personally, this is just my solution for solving leetcode problems with JavaScript/TypeScript in vscode. If it's useful for you, please recommend it to your friends!

I will also submit my solutions for some of leetcode problems in this repository, not on the main branch, but on my personal branch.

Also, contributions are welcome. If you have any ideas, just tell me in issues!

License

 _____________________________________
< The GNU General Public License v3.0 >
 -------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

A vscode workspace template with test case runner script for JavaScript/TypeScript programmers using extension LeetCode.vscode-leetcode.

Copyright (C) 2022 DarrenDanielDay [email protected]

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

See LICENSE for full contents.

You might also like...

Cloudflare worker function to update github bio automatically with leetcode and codeforces profile stats 🚀

Stats check 🔢 Cloudflare worker function to update github bio automatically with leetcode and codeforces profile stats 🚀 You can see it in action he

Feb 15, 2022

A TypeScript namespace declaration for KeyboardEvent.key strings, just in case your code is allergic to enums.

ts-key-namespace A TypeScript namespace declaration for KeyboardEvent.key strings, just in case you prefer namespaces to enums. Largely based on ts-ke

Apr 5, 2022

A name generato for everyone (Programmers, Gamers etc)

A name generato for everyone (Programmers, Gamers etc)

HACKZILLA A name generator for Programmers, Gamers and etc. Used Languages HTML5 CSS3 Javascript 🔗 🔗 Link: https://rededge967.github.io/HACKZILLA/ R

May 14, 2022

Programmers House api official wrapper

programmershouse-wrapper Programmers House api official wrapper Install: npm install programmershouse-wrapper Example of using: With .then //importing

Mar 23, 2022

A Hackable Markdown Note Application for Programmers. Version control, AI completion, mind map, documents encryption, code snippet running, integrated terminal, chart embedding, HTML applets, plug-in, and macro replacement.

A Hackable Markdown Note Application for Programmers. Version control, AI completion, mind map, documents encryption, code snippet running, integrated terminal, chart embedding, HTML applets, plug-in, and macro replacement.

Yank Note A hackable markdown note application for programmers Download | Try it Online Not ecommended English | 中文说明 [toc]{level: [2]} Highlights

Dec 31, 2022

CodeTogether is a platform that aims to bring all the developers and coders together to appreciate collaborative coding by resolving issues faced by programmers on normal IDEs/platforms

CodeTogether is a platform that aims to bring all the developers and coders together to appreciate collaborative coding by resolving issues faced by programmers on normal IDEs/platforms

CodeTogether is a platform that aims to bring all the developers and coders together to appreciate collaborative coding by resolving issues faced by programmers on normal IDEs/platforms. It allows developers to communicate with their fellow developers or collaborators through online voice call and realtime chat. Besides, the whiteboard makes the framing of an algorithm easier by helping programmers working collaboratively to discuss and plan their approach together

Jan 20, 2022

libnIDE is an IDE for DS programmers using libnds!

UPDATE: Since I haven't had a whole lot of time to spend on this and also some bugs I don't know how to fix, I am going to stop work on libnIDE. No, n

Jun 3, 2022

🚧 WIP: Bartosz Milewski's "Category Theory for Programmers" Korean translation 📚

🚧 WIP: Bartosz Milewski's

프로그래머를 위한 범주론 본 레파지토리는 Bartosz Milewsk의 Category Theory for Programmers을 번역하며 학습한 레파지토리입니다. 🗂 목차 Part 1. 범주:합성의 본질 타입과 함수 크고 작은 범주 Kleisli Categories

Aug 18, 2022

microregex is an open source and highly curated catalog of regular expression patterns. It offers programmers RegEx snippets that can be quickly exported into a variety of programming languages and distributed around teams.

microregex is an open source and highly curated catalog of regular expression patterns. It offers programmers RegEx snippets that can be quickly exported into a variety of programming languages and distributed around teams.

microregex - A catalog of RegEx patterns View Demo · Report Bug · Request Feature Loved the tool? Please consider contributing ✍️ to help it improve!

Oct 25, 2022
Owner
俺だって、本物が欲しい。
null
A simple tap test runner that can be used by any javascript interpreter.

just-tap A simple tap test runner that can be used in any client/server javascript app. Installation npm install --save-dev just-tap Usage import cre

Mark Wylde 58 Nov 7, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
A new zero-config test runner for the true minimalists

Why User-friendly - zero-config, no API to learn, simple conventions Extremely lighweight - only 40 lines of code and no dependencies Super fast - wit

null 680 Dec 20, 2022
A low-feature, dependency-free and performant test runner inspired by Rust and Deno

minitest A low-feature, dependency-free and performant test runner inspired by Rust and Deno Simplicity: Use the mt test runner with the test function

Sondre Aasemoen 4 Nov 12, 2022
Data structures & algorithms implementations and coding problem solutions. Written in Typescript and tested with Jest. Coding problems are pulled from LeetCode and Daily Coding Problem.

technical-interview-prep Data structures & algorithms implementations and coding problem solutions. Written in Typescript and tested with Jest. Coding

Lesley Chang 7 Aug 5, 2022
A learning guide for JavaScript programmers.

Table of Contents Awesome JavaScript 专题列表 基础 开发准备 推荐的书 源代码阅读 敏捷方法与工具 JavaScript ES6 Node.js 图书 最佳实践 风格指南 常用的Node Web框架 常用NPM工具模块 开发工具和库 Future Awesome

Sun 785 Dec 26, 2022
Chrome extension to save and keep track of problems from different platforms(codeforces, codechef, atcoder, leetcode etc.)

Keep Problems A Browser extension which helps to save and keep track of problems from different platforms(codeforces, codechef, atcoder, leetcode etc.

Nirav Jain 4 Aug 13, 2022
Automatically sync your leetcode solutions to your github account - top 5 trending GitHub repository

LeetHub - Automatically sync your code to GitHub. Top 5 Trending JavaScript Repositories Available on: What is LeetHub? A chrome extension that automa

Qasim Wani 2.8k Dec 31, 2022
Multiple users using the same leetcode account made easy!

LeetcodeSessionManager About This extension helps is multiple people using the same LeetCode account. It gets tiring when you create sessions(sub-acco

PAWAN JENU 34 Dec 20, 2022