diff --git a/.gitignore b/.gitignore index 003c7195..8bc32d6b 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,5 @@ out # Mac .DS_Store + +__pycache__ diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..e6525f88 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "singleQuote": false, + "trailingComma": "all", + "printWidth": 120, + "tabWidth": 4, + "jsxBracketSameLine": true +} diff --git a/.vscode/settings.json b/.vscode/settings.json index a2d0a8b1..c4e323ac 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,4 +11,4 @@ }, "tslint.autoFixOnSave": true, "tslint.ignoreDefinitionFiles": true -} \ No newline at end of file +} diff --git a/.vscodeignore b/.vscodeignore index 8cdceec0..a495b7d8 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -3,6 +3,7 @@ out/test/** test/** src/** +!src/debug/entry/** **/*.map .gitignore .travis.yml @@ -13,3 +14,4 @@ tslint.json ACKNOWLEDGEMENTS.md docs .github +__pycache__ diff --git a/README.md b/README.md index fecddd1b..c25f1295 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,25 @@ Thanks for [@yihong0618](https://github.com/yihong0618) provided a workaround wh --- +### Debug a Problem +![debug](https://raw.githubusercontent.com/jdneo/vscode-leetcode/master/docs/gifs/debug.gif) + +> Currently vscode-leetcode only support Python3 and Javascript language and in the future we will support all lanuages which support vscode debug protocal. + +> Not all problems are supported(most free problems are supported) and only supported problems have debug option. + +- Python3 debug Requirement + + - Step 1. Install a supported version of Python3 on your system (note: that the system install of Python on macOS is not supported). + + - Step 2. Install the Python extension for Visual Studio Code. + +- Javasript debug Requirement + + Nothing just vscode + +--- + ### Editor Shortcuts

Editor Shortcuts @@ -118,20 +137,20 @@ Thanks for [@yihong0618](https://github.com/yihong0618) provided a workaround wh ## Settings -| Setting Name | Description | Default Value | -| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | -| `leetcode.hideSolved` | Specify to hide the solved problems or not | `false` | -| `leetcode.showLocked` | Specify to show the locked problems or not. Only Premium users could open the locked problems | `false` | -| `leetcode.defaultLanguage` | Specify the default language used to solve the problem. Supported languages are: `bash`, `c`, `cpp`, `csharp`, `golang`, `java`, `javascript`, `kotlin`, `mysql`, `php`, `python`,`python3`,`ruby`,`rust`, `scala`,`swift` | `N/A` | -| `leetcode.useWsl` | Specify whether to use WSL or not | `false` | -| `leetcode.endpoint` | Specify the active endpoint. Supported endpoints are: `leetcode`, `leetcode-cn` | `leetcode` | -| `leetcode.workspaceFolder` | Specify the path of the workspace folder to store the problem files. | `""` | -| `leetcode.filePath` | Specify the relative path under the workspace and the file name to save the problem files. More details can be found [here](https://github.com/jdneo/vscode-leetcode/wiki/Customize-the-Relative-Folder-and-the-File-Name-of-the-Problem-File). | | -| `leetcode.enableStatusBar` | Specify whether the LeetCode status bar will be shown or not. | `true` | -| `leetcode.editor.shortcuts` | Specify the customized shorcuts in editors. Supported values are: `submit`, `test`, `solution` and `description`. | `["submit, test"]` | -| `leetcode.enableSideMode` | Specify whether `preview`, `solution` and `submission` tab should be grouped into the second editor column when solving a problem. | `true` | -| `leetcode.nodePath` | Specify the `Node.js` executable path. for example, C:\Program Files\nodejs\node.exe | `node` | -| `leetcode.showCommentDescription` | Specify whether to include the problem description in the comments | `false` | +| Setting Name | Description | Default Value | +| --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | +| `leetcode.hideSolved` | Specify to hide the solved problems or not | `false` | +| `leetcode.showLocked` | Specify to show the locked problems or not. Only Premium users could open the locked problems | `false` | +| `leetcode.defaultLanguage` | Specify the default language used to solve the problem. Supported languages are: `bash`, `c`, `cpp`, `csharp`, `golang`, `java`, `javascript`, `kotlin`, `mysql`, `php`, `python`,`python3`,`ruby`,`rust`, `scala`,`swift` | `N/A` | +| `leetcode.useWsl` | Specify whether to use WSL or not | `false` | +| `leetcode.endpoint` | Specify the active endpoint. Supported endpoints are: `leetcode`, `leetcode-cn` | `leetcode` | +| `leetcode.workspaceFolder` | Specify the path of the workspace folder to store the problem files. | `""` | +| `leetcode.filePath` | Specify the relative path under the workspace and the file name to save the problem files. More details can be found [here](https://github.com/jdneo/vscode-leetcode/wiki/Customize-the-Relative-Folder-and-the-File-Name-of-the-Problem-File). | | +| `leetcode.enableStatusBar` | Specify whether the LeetCode status bar will be shown or not. | `true` | +| `leetcode.editor.shortcuts` | Specify the customized shorcuts in editors. Supported values are: `submit`, `test`, `solution` and `description`. | `["submit, test"]` | +| `leetcode.enableSideMode` | Specify whether `preview`, `solution` and `submission` tab should be grouped into the second editor column when solving a problem. | `true` | +| `leetcode.nodePath` | Specify the `Node.js` executable path. for example, C:\Program Files\nodejs\node.exe | `node` | +| `leetcode.showCommentDescription` | Specify whether to include the problem description in the comments | `false` | ## Want Help? diff --git a/docs/README_zh-CN.md b/docs/README_zh-CN.md index 8aced3a8..8dfbca23 100644 --- a/docs/README_zh-CN.md +++ b/docs/README_zh-CN.md @@ -86,6 +86,25 @@ --- +### 调试题目 +![debug](https://raw.githubusercontent.com/jdneo/vscode-leetcode/master/docs/gifs/debug.gif) + +> 当前vscode-leetcode仅仅支持Python3和Javascript语言,未来我们会支持所有支持vscode debug protocal的语言 + +> 不是所有的题目都支持(支持大部分免费题目),只有支持的题目才有调试选项 + +- Python3调试的必要条件 + + - 步骤 1. 在系统上安装对应版本的python3 (注意: 系统安装的Python不支持)。 + + - Step 2. 安装vscode的Python插件。 + +- Javasript调试的必要条件 + + 无 + +--- + ### 编辑器快捷方式

Editor Shortcuts @@ -119,20 +138,20 @@ ## 插件配置项 -| 配置项名称 | 描述 | 默认值 | -| ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | -| `leetcode.hideSolved` | 指定是否要隐藏已解决的问题 | `false` | -| `leetcode.showLocked` | 指定是否显示付费题目,只有付费账户才可以打开付费题目 | `false` | -| `leetcode.defaultLanguage` | 指定答题时使用的默认语言,可选语言有:`bash`, `c`, `cpp`, `csharp`, `golang`, `java`, `javascript`, `kotlin`, `mysql`, `php`, `python`,`python3`,`ruby`, `rust`, `scala`,`swift` | `N/A` | -| `leetcode.useWsl` | 指定是否启用 WSL | `false` | -| `leetcode.endpoint` | 指定使用的终端,可用终端有:`leetcode`, `leetcode-cn` | `leetcode` | -| `leetcode.workspaceFolder` | 指定保存文件的工作区目录 | `""` | -| `leetcode.filePath` | 指定生成题目文件的相对文件夹路径名和文件名。点击查看[更多详细用法](https://github.com/jdneo/vscode-leetcode/wiki/%E8%87%AA%E5%AE%9A%E4%B9%89%E9%A2%98%E7%9B%AE%E6%96%87%E4%BB%B6%E7%9A%84%E7%9B%B8%E5%AF%B9%E6%96%87%E4%BB%B6%E5%A4%B9%E8%B7%AF%E5%BE%84%E5%92%8C%E6%96%87%E4%BB%B6%E5%90%8D)。 | | -| `leetcode.enableStatusBar` | 指定是否在 VS Code 下方显示插件状态栏。 | `true` | -| `leetcode.editor.shortcuts` | 指定在编辑器内所自定义的快捷方式。可用的快捷方式有: `submit`, `test`, `solution`, `description`。 | `["submit, test"]` | -| `leetcode.enableSideMode` | 指定在解决一道题时,是否将`问题预览`、`高票答案`与`提交结果`窗口集中在编辑器的第二栏。 | `true` | -| `leetcode.nodePath` | 指定 `Node.js` 可执行文件的路径。如:C:\Program Files\nodejs\node.exe | `node` | -| `leetcode.showCommentDescription` | 指定是否要在注释中显示题干。 | `false` | +| 配置项名称 | 描述 | 默认值 | +| --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | +| `leetcode.hideSolved` | 指定是否要隐藏已解决的问题 | `false` | +| `leetcode.showLocked` | 指定是否显示付费题目,只有付费账户才可以打开付费题目 | `false` | +| `leetcode.defaultLanguage` | 指定答题时使用的默认语言,可选语言有:`bash`, `c`, `cpp`, `csharp`, `golang`, `java`, `javascript`, `kotlin`, `mysql`, `php`, `python`,`python3`,`ruby`, `rust`, `scala`,`swift` | `N/A` | +| `leetcode.useWsl` | 指定是否启用 WSL | `false` | +| `leetcode.endpoint` | 指定使用的终端,可用终端有:`leetcode`, `leetcode-cn` | `leetcode` | +| `leetcode.workspaceFolder` | 指定保存文件的工作区目录 | `""` | +| `leetcode.filePath` | 指定生成题目文件的相对文件夹路径名和文件名。点击查看[更多详细用法](https://github.com/jdneo/vscode-leetcode/wiki/%E8%87%AA%E5%AE%9A%E4%B9%89%E9%A2%98%E7%9B%AE%E6%96%87%E4%BB%B6%E7%9A%84%E7%9B%B8%E5%AF%B9%E6%96%87%E4%BB%B6%E5%A4%B9%E8%B7%AF%E5%BE%84%E5%92%8C%E6%96%87%E4%BB%B6%E5%90%8D)。 | | +| `leetcode.enableStatusBar` | 指定是否在 VS Code 下方显示插件状态栏。 | `true` | +| `leetcode.editor.shortcuts` | 指定在编辑器内所自定义的快捷方式。可用的快捷方式有: `submit`, `test`, `solution`, `description`。 | `["submit, test"]` | +| `leetcode.enableSideMode` | 指定在解决一道题时,是否将`问题预览`、`高票答案`与`提交结果`窗口集中在编辑器的第二栏。 | `true` | +| `leetcode.nodePath` | 指定 `Node.js` 可执行文件的路径。如:C:\Program Files\nodejs\node.exe | `node` | +| `leetcode.showCommentDescription` | 指定是否要在注释中显示题干。 | `false` | ## 需要帮助? 在遇到任何问题时,可以先查看一下[疑难解答](https://github.com/jdneo/vscode-leetcode/wiki/%E7%96%91%E9%9A%BE%E8%A7%A3%E7%AD%94)以及[常见问题](https://github.com/jdneo/vscode-leetcode/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98)寻求帮助。 diff --git a/docs/gifs/debug.gif b/docs/gifs/debug.gif new file mode 100644 index 00000000..95b506eb Binary files /dev/null and b/docs/gifs/debug.gif differ diff --git a/package-lock.json b/package-lock.json index 0a555853..bd8dfb15 100644 --- a/package-lock.json +++ b/package-lock.json @@ -73,8 +73,7 @@ "acorn": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-2.7.0.tgz", - "integrity": "sha1-q259nYhqrKiwhbwzEreaGYQz8Oc=", - "optional": true + "integrity": "sha1-q259nYhqrKiwhbwzEreaGYQz8Oc=" }, "acorn-globals": { "version": "1.0.9", @@ -417,8 +416,7 @@ "diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==" }, "dom-serializer": { "version": "0.1.1", @@ -853,6 +851,11 @@ "invert-kv": "^1.0.0" } }, + "leetcode-problem-types": { + "version": "0.1.0", + "resolved": "https://registry.npm.taobao.org/leetcode-problem-types/download/leetcode-problem-types-0.1.0.tgz", + "integrity": "sha1-RiC6OrmqMUR8IWuwRLm++vrgd/A=" + }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", @@ -1195,8 +1198,7 @@ "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", - "optional": true + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" }, "prompt": { "version": "1.0.0", @@ -1539,7 +1541,6 @@ "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "optional": true, "requires": { "prelude-ls": "~1.1.2" } diff --git a/src/commands/test.ts b/src/commands/test.ts index d070c9aa..d04455f6 100644 --- a/src/commands/test.ts +++ b/src/commands/test.ts @@ -1,17 +1,21 @@ // Copyright (c) jdneo. All rights reserved. // Licensed under the MIT license. +import * as fs from "fs"; import * as fse from "fs-extra"; import * as vscode from "vscode"; +import { debugExecutor } from "../debug/debugExecutor"; +import problemTypes from "../debug/problemTypes"; import { leetCodeExecutor } from "../leetCodeExecutor"; import { leetCodeManager } from "../leetCodeManager"; import { IQuickItemEx, UserStatus } from "../shared"; -import { isWindows, usingCmd } from "../utils/osUtils"; +import { fileMeta, parseTestString } from "../utils/problemUtils"; import { DialogType, promptForOpenOutputChannel, showFileSelectDialog } from "../utils/uiUtils"; import { getActiveFilePath } from "../utils/workspaceUtils"; -import * as wsl from "../utils/wslUtils"; import { leetCodeSubmissionProvider } from "../webview/leetCodeSubmissionProvider"; +const supportDebugLanguages: string[] = ["javascript", "python3"]; + export async function testSolution(uri?: vscode.Uri): Promise { try { if (leetCodeManager.getStatus() === UserStatus.SignedOut) { @@ -43,6 +47,25 @@ export async function testSolution(uri?: vscode.Uri): Promise { value: ":file", }, ); + + const fileContent: Buffer = fs.readFileSync(filePath); + const meta: { id: string, lang: string } | null = fileMeta(fileContent.toString()); + + if (meta != null && supportDebugLanguages.indexOf(meta.lang) !== -1 && problemTypes[meta.id] != null) { + picks.push({ + label: "$(three-bars) Debug by default test cases", + description: "", + detail: "Debug by default test cases", + value: ":debug-default", + }); + picks.push({ + label: "$(pencil) Debug by writing directly...", + description: "", + detail: "Debug by writing test cases in input box", + value: ":debug-direct", + }); + } + const choice: IQuickItemEx | undefined = await vscode.window.showQuickPick(picks); if (!choice) { return; @@ -75,6 +98,20 @@ export async function testSolution(uri?: vscode.Uri): Promise { } } break; + case ":debug-default": + result = await debugExecutor.execute(filePath, problemTypes[meta!.id]!.testCase.replace(/"/g, '\\"'), meta!.lang); + break; + case ":debug-direct": + const ts: string | undefined = await vscode.window.showInputBox({ + prompt: "Enter the test cases.", + validateInput: (s: string): string | undefined => s && s.trim() ? undefined : "Test case must not be empty.", + placeHolder: "Example: [1,2,3]\\n4", + ignoreFocusOut: true, + }); + if (ts) { + result = await debugExecutor.execute(filePath, ts.replace(/"/g, '\\"'), meta!.lang); + } + break; default: break; } @@ -86,17 +123,3 @@ export async function testSolution(uri?: vscode.Uri): Promise { await promptForOpenOutputChannel("Failed to test the solution. Please open the output channel for details.", DialogType.error); } } - -function parseTestString(test: string): string { - if (wsl.useWsl() || !isWindows()) { - return `'${test}'`; - } - - // In windows and not using WSL - if (usingCmd()) { - return `"${test.replace(/"/g, '\\"')}"`; - } else { - // Assume using PowerShell - return `'${test.replace(/"/g, '\\"')}'`; - } -} diff --git a/src/debug/debugExecutor.ts b/src/debug/debugExecutor.ts new file mode 100644 index 00000000..8b6e1065 --- /dev/null +++ b/src/debug/debugExecutor.ts @@ -0,0 +1,183 @@ +import * as fse from "fs-extra"; +import * as net from "net"; +// import * as path from "path"; +import * as vscode from "vscode"; +import { leetCodeChannel } from "../leetCodeChannel"; +import { leetCodeExecutor } from "../leetCodeExecutor"; +import { fileMeta, getEntryFile, parseTestString } from "../utils/problemUtils"; +import { leetCodeSubmissionProvider } from "../webview/leetCodeSubmissionProvider"; +import problemTypes from "./problemTypes"; + +interface IDebugConfig { + type: string; + program?: string; + env?: { + [key: string]: any; + }; +} + +const debugConfigMap: Map = new Map([ + [ + "javascript", + { + type: "node", + }, + ], + [ + "python3", + { + type: "python", + env: { + PYTHONPATH: "", + }, + }, + ], +]); + +interface IProblemType { + funName: string; + paramTypes: string[]; + returnType: string; + testCase: string; + specialFunName?: { + [x: string]: string; + }; +} + +interface IDebugResult { + type: "success" | "error"; + message: string; + problemNum: number; + language: string; + filePath: string; + testString: string; +} + +class DebugExecutor { + private server: net.Server; + + constructor() { + this.start(); + } + + public async execute(filePath: string, testString: string, language: string): Promise { + if (this.server == null || this.server.address() == null) { + vscode.window.showErrorMessage("Debug server error, maybe you can restart vscode."); + } + + const debugConfig: undefined | IDebugConfig = debugConfigMap.get(language); + if (debugConfig == null) { + vscode.window.showErrorMessage("Notsupported language."); + return; + } + + const fileContent: Buffer = await fse.readFile(filePath); + const meta: { id: string; lang: string } | null = fileMeta(fileContent.toString()); + if (meta == null) { + vscode.window.showErrorMessage( + "File meta info has been changed, please check the content: '@lc app=leetcode.cn id=xx lang=xx'.", + ); + return; + } + const problemType: IProblemType = problemTypes[meta.id]; + if (problemType == null) { + vscode.window.showErrorMessage(`Notsupported problem: ${meta.id}.`); + return; + } + + // const extDir: string = vscode.extensions.getExtension("shengchen.vscode-leetcode")!.extensionPath; + debugConfig.program = await getEntryFile(meta.lang, meta.id); + + const funName: string = this.getProblemFunName(language, problemType); + + if (language === "javascript") { + // check whether module.exports is exist or not + const moduleExportsReg: RegExp = new RegExp(`module.exports = ${problemType.funName};`); + if (!moduleExportsReg.test(fileContent.toString())) { + fse.writeFile( + filePath, + fileContent.toString() + + `\n// @after-stub-for-debug-begin\nmodule.exports = ${funName};\n// @after-stub-for-debug-end`, + ); + } + } else if (language === "python3") { + // check whether module.exports is exist or not + const moduleExportsReg: RegExp = /# @before-stub-for-debug-begin/; + if (!moduleExportsReg.test(fileContent.toString())) { + await fse.writeFile( + filePath, + `# @before-stub-for-debug-begin\nfrom python3problem${meta.id} import *\nfrom typing import *\n# @before-stub-for-debug-end\n\n` + + fileContent.toString(), + ); + } + debugConfig.env!.PYTHONPATH = debugConfig.program; + } + + const args: string[] = [ + filePath, + testString, + problemType.funName, + problemType.paramTypes.join(","), + problemType.returnType, + meta.id, + this.server.address().port.toString(), + ]; + vscode.debug.startDebugging( + undefined, + Object.assign({}, debugConfig, { + request: "launch", + name: "Launch Program", + args, + }), + ); + + return; + } + + /** + * for some problem have special function name + * @param language + * @param problemType + */ + private getProblemFunName(language: string, problemType: IProblemType): string { + if (problemType.specialFunName && problemType.specialFunName[language]) { + return problemType.specialFunName[language]; + } + return problemType.funName; + } + + private async start(): Promise { + this.server = net.createServer((clientSock: net.Socket) => { + clientSock.setEncoding("utf8"); + + clientSock.on("data", async (data: Buffer) => { + const result: IDebugResult = JSON.parse(data.toString()); + if (result.type === "error") { + vscode.window.showErrorMessage(result.message); + } else { + const leetcodeResult: string = await leetCodeExecutor.testSolution( + result.filePath, + parseTestString(result.testString.replace(/\\"/g, '"')), + ); + if (!leetcodeResult) { + return; + } + leetCodeSubmissionProvider.show(leetcodeResult); + } + }); + + clientSock.on("error", (error: Error) => { + leetCodeChannel.appendLine(error.toString()); + }); + }); + + this.server.on("error", (error: Error) => { + leetCodeChannel.appendLine(error.toString()); + }); + + // listen on a random port + this.server.listen({ port: 0, host: "127.0.0.1" }); + } +} + +export const debugExecutor: DebugExecutor = new DebugExecutor(); diff --git a/src/debug/entry/javascript/entry.js b/src/debug/entry/javascript/entry.js new file mode 100644 index 00000000..a9a326df --- /dev/null +++ b/src/debug/entry/javascript/entry.js @@ -0,0 +1,371 @@ +var net = require("net"); + +const fun = require(process.argv[2]); +const testString = process.argv[3]; +const paramTypes = process.argv[5].split(","); +const problemNum = parseInt(process.argv[7]); +const debugServerPort = parseInt(process.argv[8]); + +const sock = net.connect( + { + port: debugServerPort, + host: "127.0.0.1", + }, + function() { + start(); + }, +); +sock.setNoDelay(true); + +function onClose() { + setTimeout(() => { + if (sock != null) { + sock.end(); + } + process.exit(0); + }, 2000); +} + +function makeMessage(type, message) { + return JSON.stringify({ + type, + message, + problemNum, + filePath: process.argv[2], + testString, + language: "javascript", + }); +} + +function onError(err) { + sock.write(makeMessage("error", err)); + onClose(); +} + +function onSuccess() { + sock.write(makeMessage("success", "")); + onClose(); +} + +process.on("uncaughtException", function(err) { + onError(err.message + "\n" + err.stack); + throw err; +}); + +function onParameterError() { + throw new Error("Parameters parsing error, please check the format of the input parameters"); +} + +function onParameterTypeError(type) { + throw new Error(`Unsupported parameter type: ${type}`); +} + +function isNumber(num) { + return num === +num; +} + +function isString(str) { + return typeof str === "string"; +} + +function isCharacter(str) { + return isString(str) && str.length === 1; +} + +function parseNumber(param) { + if (!isNumber(param)) { + onParameterError(); + } + return param; +} + +function parseNumberArray(param) { + if (!Array.isArray(param)) { + onParameterError(); + } + param.map(p => { + if (!isNumber(p)) { + onParameterError(); + } + }); + return param; +} + +function parseString(param) { + if (!isString(param)) { + onParameterError(); + } + return param; +} + +function parseStringArray(param) { + if (!Array.isArray(param)) { + onParameterError(); + } + param.map(p => { + if (!isString(p)) { + onParameterError(); + } + }); + return param; +} + +function parseStringArrayArray(param) { + if (!Array.isArray(param)) { + onParameterError(); + } + param.map(p => { + if (!parseStringArray(p)) { + onParameterError(); + } + }); + return param; +} + +function ListNode(val) { + this.val = val; + this.next = null; +} + +function parseListNode(param) { + if (!Array.isArray(param)) { + onParameterError(); + } + + let head = null; + let tail = null; + param.map(p => { + const node = new ListNode(p); + if (head == null) { + tail = node; + head = node; + } else { + tail.next = node; + tail = node; + } + }); + return head; +} + +function parseListNodeArray(param) { + if (!Array.isArray(param)) { + onParameterError(); + } + + const res = param.map(p => { + return parseListNode(p); + }); + return res; +} + +function parseNumberArrayArray(param) { + if (!Array.isArray(param)) { + onParameterError(); + } + param.map(p => { + return parseNumberArray(p); + }); + return param; +} + +function parseCharacter(param) { + if (!isCharacter(param)) { + onParameterError(); + } + return param; +} + +function parseCharacterArray(param) { + if (!Array.isArray(param)) { + onParameterError(); + } + param.map(p => { + if (!isCharacter(p)) { + onParameterError(); + } + }); + return param; +} + +function parseCharacterArrayArray(param) { + if (!Array.isArray(param)) { + onParameterError(); + } + param.map(p => { + parseCharacterArray(p); + }); + return param; +} + +function NestedInteger(ni) { + let nested = []; + if (Array.isArray(ni)) { + ni.map(n => { + nested.push(new NestedInteger(n)); + }); + } + + /** + * Return true if this NestedInteger holds a single integer, rather than a nested list. + * @return { boolean } + */ + this.isInteger = function() { + if (Array.isArray(ni)) { + return false; + } + return true; + }; + + /** + * Return the single integer that this NestedInteger holds, if it holds a single integer + * Return null if this NestedInteger holds a nested list + * @return { integer } + */ + this.getInteger = function() { + if (Array.isArray(ni)) { + return null; + } + return ni; + }; + + /** + * Return the nested list that this NestedInteger holds, if it holds a nested list + * Return null if this NestedInteger holds a single integer + * @return { NestedInteger[] } + */ + this.getList = function() { + if (Array.isArray(ni)) { + return nested; + } + return null; + }; +} + +function parseNestedIntegerArray(param) { + return param.map(p => { + return new NestedInteger(p); + }); +} + +function parseMountainArray(param) { + if (!Array.isArray(param)) { + onParameterError(); + } + function MountainArray() { + /** + * @param {integer} index + * @return {integer} + */ + this.get = function(index) { + return param[index]; + }; + + /** + * @return {integer} + */ + this.length = function() { + return param.length; + }; + } + return new MountainArray(); +} + +function TreeNode(val) { + this.val = val; + this.left = this.right = null; +} + +function parseTreeNode(param) { + if (!Array.isArray(param)) { + onParameterError(); + } + + let root = null; + const fifo = []; + let i = 0; + while (i < param.length) { + if (i === 0) { + root = new TreeNode(param[i]); + i += 1; + fifo.push(root); + continue; + } + const parent = fifo.shift(); + if (param[i] != null) { + const left = new TreeNode(param[i]); + parent.left = left; + fifo.push(left); + } + if (i + 1 < param.length && param[i + 1] != null) { + const right = new TreeNode(param[i + 1]); + parent.right = right; + fifo.push(right); + } + i = i + 2; + } + return root; +} + +function parseParameter(index, type, param) { + switch (type) { + case "number": + return parseNumber(param); + case "number[]": + return parseNumberArray(param); + case "number[][]": + return parseNumberArrayArray(param); + case "string": + return parseString(param); + case "string[]": + return parseStringArray(param); + case "string[][]": + return parseStringArrayArray(param); + case "ListNode": + return parseListNode(param); + case "ListNode[]": + return parseListNodeArray(param); + case "character": + return parseCharacter(param); + case "character[]": + return parseCharacterArray(param); + case "character[][]": + return parseCharacterArrayArray(param); + case "NestedInteger[]": + return parseNestedIntegerArray(param); + case "MountainArray": + return parseMountainArray(param); + case "TreeNode": + return parseTreeNode(param); + } + const result = parseSpecialParameter(index, type, param); + if (result == null) { + onParameterTypeError(type); + } + return result; +} + +// @@stub-for-code@@ + +function parseParamsToJson(paramString) { + let params; + try { + const paramsByLine = paramString.split(/\\n/); + + params = paramsByLine.map(str => { + return JSON.parse(str); + }); + + return params; + } catch (error) { + onParameterError(); + return; + } +} + +function start() { + const paramString = testString.replace(/\\"/g, '"'); + const jsonParams = parseParamsToJson(paramString); + + runUserScript(fun, jsonParams, paramTypes); + onSuccess(); +} diff --git a/src/debug/entry/javascript/problems/1095.js b/src/debug/entry/javascript/problems/1095.js new file mode 100644 index 00000000..c7feabf9 --- /dev/null +++ b/src/debug/entry/javascript/problems/1095.js @@ -0,0 +1,11 @@ +function runUserScript(userFunm, params, paramTypes) { + if (params.length !== 2) { + onParameterError(); + } + userFunm.apply(null, [parseParameter(0, 'number', params[1]), parseParameter(1, 'MountainArray', params[0])]); +} + + +function parseSpecialParameter(index, type, param) { + return null; +} diff --git a/src/debug/entry/javascript/problems/116.js b/src/debug/entry/javascript/problems/116.js new file mode 100644 index 00000000..a8be77a9 --- /dev/null +++ b/src/debug/entry/javascript/problems/116.js @@ -0,0 +1,45 @@ +function runUserScript(userFunm, params, paramTypes) { + if (params.length !== paramTypes.length) { + onParameterError(); + } + + const parsedParams = params.map((param, index) => { + const type = paramTypes[index]; + return parseParameter(index, type, param); + }); + userFunm.apply(null, parsedParams); +} + +function Node(val, left, right, next) { + this.val = val; + this.left = left; + this.right = right; + this.next = next; +} + +/** + * @param {number[]} param + */ +function parseNode(nums) { + const arr = []; + nums.map((n, i) => { + const node = new Node(n); + arr.push(node); + if (i !== 0) { + if (i % 2 === 1) { + arr[(i - 1) / 2].left = node; + } else { + arr[(i - 2) / 2].right = node; + } + } + }); + return arr[0]; +} + +function parseSpecialParameter(index, type, param) { + switch (type) { + case "Node": + return parseNode(param); + } + return null; +} diff --git a/src/debug/entry/javascript/problems/117.js b/src/debug/entry/javascript/problems/117.js new file mode 100644 index 00000000..039112d2 --- /dev/null +++ b/src/debug/entry/javascript/problems/117.js @@ -0,0 +1,52 @@ +function runUserScript(userFunm, params, paramTypes) { + if (params.length !== paramTypes.length) { + onParameterError(); + } + + const parsedParams = params.map((param, index) => { + const type = paramTypes[index]; + return parseParameter(index, type, param); + }); + userFunm.apply(null, parsedParams); +} + +function Node(val, left, right, next) { + this.val = val === undefined ? null : val; + this.left = left === undefined ? null : left; + this.right = right === undefined ? null : right; + this.next = next === undefined ? null : next; +} + +/** + * @param {number[]} param + */ +function parseNode(param) { + if (param.length == 0) { + return null; + } + const first = new Node(param[0]); + const queue = [[first, 0]]; + for (let j = 1; j < param.length; j++) { + const top = queue[0]; + const val = param[j] === null ? null : new Node(param[j]); + if (top[1] === 0) { + top[0].left = val; + top[1] = 1; + } else { + top[0].right = val; + queue.shift(); + } + if (val !== null) { + queue.push([val, 0]); + } + } + return first; +} + +function parseSpecialParameter(index, type, param) { + switch (type) { + case "Node": + return parseNode(param); + } + return null; +} diff --git a/src/debug/entry/javascript/problems/133.js b/src/debug/entry/javascript/problems/133.js new file mode 100644 index 00000000..b123b317 --- /dev/null +++ b/src/debug/entry/javascript/problems/133.js @@ -0,0 +1,40 @@ +function runUserScript(userFunm, params, paramTypes) { + if (params.length !== paramTypes.length) { + onParameterError(); + } + + const parsedParams = params.map((param, index) => { + const type = paramTypes[index]; + return parseParameter(index, type, param); + }); + userFunm.apply(null, parsedParams); +} + +function Node(val, neighbors) { + this.val = val; + this.neighbors = neighbors; +} + +/** + * @param {number[][]} param + */ +function parseNode(nums) { + const arr = []; + nums.map((n, i) => { + arr.push(new Node(i + 1, [])); + }); + nums.map((nei, i) => { + nei.map(k => { + arr[i].neighbors.push(arr[k - 1]); + }); + }); + return arr[0]; +} + +function parseSpecialParameter(index, type, param) { + switch (type) { + case "Node": + return parseNode(param); + } + return null; +} diff --git a/src/debug/entry/javascript/problems/138.js b/src/debug/entry/javascript/problems/138.js new file mode 100644 index 00000000..709b1be4 --- /dev/null +++ b/src/debug/entry/javascript/problems/138.js @@ -0,0 +1,44 @@ +function runUserScript(userFunm, params, paramTypes) { + if (params.length !== paramTypes.length) { + onParameterError(); + } + + const parsedParams = params.map((param, index) => { + const type = paramTypes[index]; + return parseParameter(index, type, param); + }); + userFunm.apply(null, parsedParams); +} + +function Node(val, next, random) { + this.val = val; + this.next = next; + this.random = random; +} + +/** + * @param {number[][]} param + */ +function parseNode(nums) { + const arr = []; + nums.map((n, i) => { + arr.push(new Node(n[0], null, null)); + }); + nums.map((n, i) => { + if (i !== nums.length - 1) { + arr[i].next = arr[i + 1]; + } + if (n[1] !== null) { + arr[i].random = arr[n[1]]; + } + }); + return arr[0]; +} + +function parseSpecialParameter(index, type, param) { + switch (type) { + case "Node": + return parseNode(param); + } + return null; +} diff --git a/src/debug/entry/javascript/problems/278.js b/src/debug/entry/javascript/problems/278.js new file mode 100644 index 00000000..6e14d71b --- /dev/null +++ b/src/debug/entry/javascript/problems/278.js @@ -0,0 +1,19 @@ +function runUserScript(userFunm, params, paramTypes) { + if (params.length !== 2) { + onParameterError(); + } + const version = params[1]; + const n = params[0]; + const isBadVersion = function (k) { + if (k >= version) { + return true; + } + return false; + } + userFunm(isBadVersion)(n); +} + + +function parseSpecialParameter(index, type, param) { + return null; +} diff --git a/src/debug/entry/javascript/problems/429.js b/src/debug/entry/javascript/problems/429.js new file mode 100644 index 00000000..6b365d37 --- /dev/null +++ b/src/debug/entry/javascript/problems/429.js @@ -0,0 +1,46 @@ +function runUserScript(userFunm, params, paramTypes) { + if (params.length !== paramTypes.length) { + onParameterError(); + } + + const parsedParams = params.map((param, index) => { + const type = paramTypes[index]; + return parseParameter(index, type, param); + }); + userFunm.apply(null, parsedParams); +} + +function Node(val, children) { + this.val = val; + this.children = children; +} + +/** + * @param {number[]} param + */ +function parseNode(param) { + if (param.length === 0) { + return null; + } + const first = new Node(param[0], []); + const queue = [first]; + for (let j = 2; j < param.length; j++) { + const top = queue[0]; + if (param[j] === null) { + queue.shift(); + } else { + const child = new Node(param[j], []); + top.children.push(child); + queue.push(child); + } + } + return first; +} + +function parseSpecialParameter(index, type, param) { + switch (type) { + case "Node": + return parseNode(param); + } + return null; +} diff --git a/src/debug/entry/javascript/problems/559.js b/src/debug/entry/javascript/problems/559.js new file mode 100644 index 00000000..6b365d37 --- /dev/null +++ b/src/debug/entry/javascript/problems/559.js @@ -0,0 +1,46 @@ +function runUserScript(userFunm, params, paramTypes) { + if (params.length !== paramTypes.length) { + onParameterError(); + } + + const parsedParams = params.map((param, index) => { + const type = paramTypes[index]; + return parseParameter(index, type, param); + }); + userFunm.apply(null, parsedParams); +} + +function Node(val, children) { + this.val = val; + this.children = children; +} + +/** + * @param {number[]} param + */ +function parseNode(param) { + if (param.length === 0) { + return null; + } + const first = new Node(param[0], []); + const queue = [first]; + for (let j = 2; j < param.length; j++) { + const top = queue[0]; + if (param[j] === null) { + queue.shift(); + } else { + const child = new Node(param[j], []); + top.children.push(child); + queue.push(child); + } + } + return first; +} + +function parseSpecialParameter(index, type, param) { + switch (type) { + case "Node": + return parseNode(param); + } + return null; +} diff --git a/src/debug/entry/javascript/problems/589.js b/src/debug/entry/javascript/problems/589.js new file mode 100644 index 00000000..6b365d37 --- /dev/null +++ b/src/debug/entry/javascript/problems/589.js @@ -0,0 +1,46 @@ +function runUserScript(userFunm, params, paramTypes) { + if (params.length !== paramTypes.length) { + onParameterError(); + } + + const parsedParams = params.map((param, index) => { + const type = paramTypes[index]; + return parseParameter(index, type, param); + }); + userFunm.apply(null, parsedParams); +} + +function Node(val, children) { + this.val = val; + this.children = children; +} + +/** + * @param {number[]} param + */ +function parseNode(param) { + if (param.length === 0) { + return null; + } + const first = new Node(param[0], []); + const queue = [first]; + for (let j = 2; j < param.length; j++) { + const top = queue[0]; + if (param[j] === null) { + queue.shift(); + } else { + const child = new Node(param[j], []); + top.children.push(child); + queue.push(child); + } + } + return first; +} + +function parseSpecialParameter(index, type, param) { + switch (type) { + case "Node": + return parseNode(param); + } + return null; +} diff --git a/src/debug/entry/javascript/problems/590.js b/src/debug/entry/javascript/problems/590.js new file mode 100644 index 00000000..6b365d37 --- /dev/null +++ b/src/debug/entry/javascript/problems/590.js @@ -0,0 +1,46 @@ +function runUserScript(userFunm, params, paramTypes) { + if (params.length !== paramTypes.length) { + onParameterError(); + } + + const parsedParams = params.map((param, index) => { + const type = paramTypes[index]; + return parseParameter(index, type, param); + }); + userFunm.apply(null, parsedParams); +} + +function Node(val, children) { + this.val = val; + this.children = children; +} + +/** + * @param {number[]} param + */ +function parseNode(param) { + if (param.length === 0) { + return null; + } + const first = new Node(param[0], []); + const queue = [first]; + for (let j = 2; j < param.length; j++) { + const top = queue[0]; + if (param[j] === null) { + queue.shift(); + } else { + const child = new Node(param[j], []); + top.children.push(child); + queue.push(child); + } + } + return first; +} + +function parseSpecialParameter(index, type, param) { + switch (type) { + case "Node": + return parseNode(param); + } + return null; +} diff --git a/src/debug/entry/javascript/problems/843.js b/src/debug/entry/javascript/problems/843.js new file mode 100644 index 00000000..283eb632 --- /dev/null +++ b/src/debug/entry/javascript/problems/843.js @@ -0,0 +1,25 @@ +function runUserScript(userFunm, params, paramTypes) { + if (params.length !== 3) { + onParameterError(); + } + function Master(secret, wordlist) { + this.guess = function(word) { + if (!wordlist.includes(word)) { + return -1; + } + + let match = 0; + for (let i = 0; i < word.length; i++) { + if (word[i] === secret[i]) { + match += 1; + } + } + return match; + }; + } + userFunm(params[1], new Master(params[0], params[1])); +} + +function parseSpecialParameter(index, type, param) { + return null; +} diff --git a/src/debug/entry/javascript/problems/common.js b/src/debug/entry/javascript/problems/common.js new file mode 100644 index 00000000..b41768c9 --- /dev/null +++ b/src/debug/entry/javascript/problems/common.js @@ -0,0 +1,16 @@ +function runUserScript(userFunm, params, paramTypes) { + if (params.length !== paramTypes.length) { + onParameterError(); + } + + const parsedParams = params.map((param, index) => { + const type = paramTypes[index]; + return parseParameter(index, type, param); + }); + userFunm.apply(null, parsedParams); +} + + +function parseSpecialParameter(index, type, param) { + return null; +} diff --git a/src/debug/entry/python3/entry.py b/src/debug/entry/python3/entry.py new file mode 100644 index 00000000..fd1aab30 --- /dev/null +++ b/src/debug/entry/python3/entry.py @@ -0,0 +1,229 @@ +import importlib.util +import sys +from pathlib import Path +import json +import re +import socket + +testString = str(sys.argv[2]) +funcName = str(sys.argv[3]) +paramTypes = str(sys.argv[4]).split(",") +problemNum = int(sys.argv[6]) +debugServerPort = int(sys.argv[7]) + + +class ListNode: + def __init__(self, x): + self.val = x + self.next = None + + +def onParameterError(): + raise Exception( + "Parameters parsing error, please check the format of the input parameters") + + +def onParameterTypeError(t): + raise Exception("Unsupported parameter type: {}".format(t)) + + +def isNumber(num): + return isinstance(num, int) + + +def isString(s): + return isinstance(s, str) + + +def isCharacter(s): + return isString(s) and len(s) == 1 + + +def isList(li): + return isinstance(li, list) + + +def parseNumber(param): + if (not isNumber(param)): + onParameterError() + return param + + +def parseNumberArray(param): + if (not isList(param)): + onParameterError() + + for i in param: + if (not isNumber(i)): + onParameterError() + return param + + +def parseNumberArrayArray(param): + if (not isList(param)): + onParameterError() + for i in param: + parseNumberArray(i) + return param + + +def parseString(param): + if (not isString(param)): + onParameterError() + + return param + + +def parseStringArray(param): + if (not isList(param)): + onParameterError() + + for i in param: + parseString(i) + + return param + + +def parseStringArrayArray(param): + if (not isList(param)): + onParameterError() + + for i in param: + parseStringArray(i) + + return param + + +def parseListNode(param): + if (not isList(param)): + onParameterError() + + head = None + tail = None + + for i in param: + node = ListNode(i) + if (head == None): + tail = node + head = node + else: + tail.next = node + tail = node + + return head + + +def parseListNodeArray(param): + if (not isList(param)): + onParameterError() + + res = [] + for i in param: + res.append(parseListNode(i)) + + return res + + +def parseCharacter(param): + if (not isCharacter(param)): + onParameterError() + + return param + + +def parseCharacterArray(param): + if (not isList(param)): + onParameterError() + + for i in param: + parseCharacter(i) + + return param + + +def parseCharacterArrayArray(param): + if (not isList(param)): + onParameterError() + + for i in param: + parseCharacterArray(i) + + return param + + +def parseParameter(index, paramType, param): + switch = { + "number": lambda x: parseNumber(x), + "number[]": lambda x: parseNumberArray(x), + "number[][]": lambda x: parseNumberArrayArray(x), + "string": lambda x: parseString(x), + "string[]": lambda x: parseStringArray(x), + "string[][]": lambda x: parseStringArrayArray(x), + "ListNode": lambda x: parseListNode(x), + "ListNode[]": lambda x: parseListNodeArray(x), + "character": lambda x: parseCharacter(x), + "character[]": lambda x: parseCharacterArray(x), + "character[][]": lambda x: parseCharacterArrayArray(x), + } + switchfun = switch.get(paramType, 0) + + if switchfun is 0: + result = parseSpecialParameter(index, paramType, param) + if result is None: + onParameterTypeError(paramType) + return result + else: + return switchfun(param) + + +def loadModule(): + # add module to search path + parsedPath = Path(sys.argv[1]) + sys.path.append(parsedPath.parent) + + # load module + spec = importlib.util.spec_from_file_location(parsedPath.stem, sys.argv[1]) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +// @@stub-for-code@@ + + +def start(): + module = loadModule() + solution = module.Solution() + func = getattr(solution, funcName) + + lines = testString.split("\\n") + + params = [] + for i, val in enumerate(lines): + params.append(json.loads(val)) + + runUserScript(func, params, paramTypes) + + +def makeMessage(ty, message): + return json.dumps({ + "type": ty, + "message": message, + "problemNum": problemNum, + "filePath": sys.argv[1], + "testString": testString, + "language": "python", + }).encode("utf-8") + + +if __name__ == "__main__": + sock = socket.socket() + sock.connect(("127.0.0.1", debugServerPort)) + try: + start() + sock.send(makeMessage("success", "")) + except Exception as identifier: + sock.send(makeMessage("error", str(identifier))) + raise identifier + finally: + sock.close() diff --git a/src/debug/entry/python3/problems/1095.js b/src/debug/entry/python3/problems/1095.js new file mode 100644 index 00000000..e1e59be3 --- /dev/null +++ b/src/debug/entry/python3/problems/1095.js @@ -0,0 +1,11 @@ +function runUserScript(userFunm, params, paramTypes) { + if (params.length !== 2) { + onParameterError(); + } + userFunm.apply(null, [parseParameter(0, 'number', params[1]), parseParameter(1, 'MountainArray', params[0])]); +} + + +function parseSpecialParameter(index, type, param) { + return null; +} diff --git a/src/debug/entry/python3/problems/116.py b/src/debug/entry/python3/problems/116.py new file mode 100644 index 00000000..bb95be52 --- /dev/null +++ b/src/debug/entry/python3/problems/116.py @@ -0,0 +1,37 @@ +def runUserScript(func, params, paramTypes): + if (len(params) != len(paramTypes)): + onParameterError() + + newParams = [] + for i, val in enumerate(params): + newParams.append(parseParameter(i, paramTypes[i], val)) + func(*newParams) + + +class Node: + def __init__(self, val, left, right, next): + self.val = val + self.left = left + self.right = right + self.next = next + + +def parseNode(param): + arr = [] + + for i, val in enumerate(param): + node = Node(val, None, None, None) + arr.append(node) + if i is not 0: + if i % 2 is 1: + arr[int((i - 1) / 2)].left = node + else: + arr[int((i - 2) / 2)].right = node + + return arr[0] + + +def parseSpecialParameter(index, paramType, param): + if paramType == "Node": + return parseNode(param) + return None diff --git a/src/debug/entry/python3/problems/117.py b/src/debug/entry/python3/problems/117.py new file mode 100644 index 00000000..d4db2669 --- /dev/null +++ b/src/debug/entry/python3/problems/117.py @@ -0,0 +1,46 @@ +def runUserScript(func, params, paramTypes): + if (len(params) != len(paramTypes)): + onParameterError() + + newParams = [] + for i, val in enumerate(params): + newParams.append(parseParameter(i, paramTypes[i], val)) + func(*newParams) + + +class Node: + def __init__(self, val, left, right, next): + self.val = val + self.left = left + self.right = right + self.next = next + + +def parseNode(param): + first = Node(param[0], None, None, None) + arr = [] + arr.append([first, 0]) + + for i, val in enumerate(param): + if i is 0: + continue + + top = arr[0] + val = None if param[i] is None else Node(param[i], None, None, None) + if top[1] is 0: + top[0].left = val + top[1] = 1 + else: + top[0].right = val + arr.pop(0) + + if val is not None: + arr.append([val, 0]) + + return first + + +def parseSpecialParameter(index, paramType, param): + if paramType == "Node": + return parseNode(param) + return None diff --git a/src/debug/entry/python3/problems/133.py b/src/debug/entry/python3/problems/133.py new file mode 100644 index 00000000..0ae22a40 --- /dev/null +++ b/src/debug/entry/python3/problems/133.py @@ -0,0 +1,32 @@ +def runUserScript(func, params, paramTypes): + if (len(params) != len(paramTypes)): + onParameterError() + + newParams = [] + for i, val in enumerate(params): + newParams.append(parseParameter(i, paramTypes[i], val)) + func(*newParams) + + +class Node: + def __init__(self, val, neighbors): + self.val = val + self.neighbors = neighbors + + +def parseNode(param, nodeMap): + arr = [] + for i, val in enumerate(param): + arr.append(Node(i + 1, [])) + + for i, val in enumerate(param): + for j, k in enumerate(val): + arr[i].neighbors.append(arr[k - 1]) + + return arr[0] + + +def parseSpecialParameter(index, paramType, param): + if paramType == "Node": + return parseNode(param, None) + return None diff --git a/src/debug/entry/python3/problems/138.py b/src/debug/entry/python3/problems/138.py new file mode 100644 index 00000000..559c6e63 --- /dev/null +++ b/src/debug/entry/python3/problems/138.py @@ -0,0 +1,36 @@ +def runUserScript(func, params, paramTypes): + if (len(params) != len(paramTypes)): + onParameterError() + + newParams = [] + for i, val in enumerate(params): + newParams.append(parseParameter(i, paramTypes[i], val)) + func(*newParams) + + +class Node: + def __init__(self, val, next, random): + self.val = val + self.next = next + self.random = random + + +def parseNode(param, nodeMap): + arr = [] + for i, val in enumerate(param): + arr.append(Node(val[0], None, None)) + + for i, val in enumerate(param): + if i is not len(param) - 1: + arr[i].next = arr[i + 1] + + if val[1] is not None: + arr[i].random = arr[val[1]] + + return arr[0] + + +def parseSpecialParameter(index, paramType, param): + if paramType == "Node": + return parseNode(param, None) + return None diff --git a/src/debug/entry/python3/problems/278.py b/src/debug/entry/python3/problems/278.py new file mode 100644 index 00000000..057372b5 --- /dev/null +++ b/src/debug/entry/python3/problems/278.py @@ -0,0 +1,18 @@ +def runUserScript(func, params, paramTypes): + if (len(params) != 2): + onParameterError() + + version = params[1] + n = params[0] + + def isBadVersion(k): + if k > version: + return True + return False + + newParams = [n] + func(*newParams) + + +def parseSpecialParameter(index, paramType, param): + return None diff --git a/src/debug/entry/python3/problems/429.py b/src/debug/entry/python3/problems/429.py new file mode 100644 index 00000000..cacc9d31 --- /dev/null +++ b/src/debug/entry/python3/problems/429.py @@ -0,0 +1,45 @@ +def runUserScript(func, params, paramTypes): + if (len(params) != len(paramTypes)): + onParameterError() + + newParams = [] + for i, val in enumerate(params): + newParams.append(parseParameter(i, paramTypes[i], val)) + func(*newParams) + + +class Node: + def __init__(self, val, children): + self.val = val + self.children = children + + +def parseNode(param): + if len(param) is 0: + return + + first = Node(param[0], []) + arr = [first] + + for i, val in enumerate(param): + if i is 0: + continue + + if i is 1: + continue + + top = arr[0] + if val is None: + arr.pop(0) + else: + child = Node(val, []) + top.children.append(child) + arr.append(child) + + return first + + +def parseSpecialParameter(index, paramType, param): + if paramType == "Node": + return parseNode(param) + return None diff --git a/src/debug/entry/python3/problems/559.py b/src/debug/entry/python3/problems/559.py new file mode 100644 index 00000000..cacc9d31 --- /dev/null +++ b/src/debug/entry/python3/problems/559.py @@ -0,0 +1,45 @@ +def runUserScript(func, params, paramTypes): + if (len(params) != len(paramTypes)): + onParameterError() + + newParams = [] + for i, val in enumerate(params): + newParams.append(parseParameter(i, paramTypes[i], val)) + func(*newParams) + + +class Node: + def __init__(self, val, children): + self.val = val + self.children = children + + +def parseNode(param): + if len(param) is 0: + return + + first = Node(param[0], []) + arr = [first] + + for i, val in enumerate(param): + if i is 0: + continue + + if i is 1: + continue + + top = arr[0] + if val is None: + arr.pop(0) + else: + child = Node(val, []) + top.children.append(child) + arr.append(child) + + return first + + +def parseSpecialParameter(index, paramType, param): + if paramType == "Node": + return parseNode(param) + return None diff --git a/src/debug/entry/python3/problems/589.py b/src/debug/entry/python3/problems/589.py new file mode 100644 index 00000000..cacc9d31 --- /dev/null +++ b/src/debug/entry/python3/problems/589.py @@ -0,0 +1,45 @@ +def runUserScript(func, params, paramTypes): + if (len(params) != len(paramTypes)): + onParameterError() + + newParams = [] + for i, val in enumerate(params): + newParams.append(parseParameter(i, paramTypes[i], val)) + func(*newParams) + + +class Node: + def __init__(self, val, children): + self.val = val + self.children = children + + +def parseNode(param): + if len(param) is 0: + return + + first = Node(param[0], []) + arr = [first] + + for i, val in enumerate(param): + if i is 0: + continue + + if i is 1: + continue + + top = arr[0] + if val is None: + arr.pop(0) + else: + child = Node(val, []) + top.children.append(child) + arr.append(child) + + return first + + +def parseSpecialParameter(index, paramType, param): + if paramType == "Node": + return parseNode(param) + return None diff --git a/src/debug/entry/python3/problems/590.py b/src/debug/entry/python3/problems/590.py new file mode 100644 index 00000000..cacc9d31 --- /dev/null +++ b/src/debug/entry/python3/problems/590.py @@ -0,0 +1,45 @@ +def runUserScript(func, params, paramTypes): + if (len(params) != len(paramTypes)): + onParameterError() + + newParams = [] + for i, val in enumerate(params): + newParams.append(parseParameter(i, paramTypes[i], val)) + func(*newParams) + + +class Node: + def __init__(self, val, children): + self.val = val + self.children = children + + +def parseNode(param): + if len(param) is 0: + return + + first = Node(param[0], []) + arr = [first] + + for i, val in enumerate(param): + if i is 0: + continue + + if i is 1: + continue + + top = arr[0] + if val is None: + arr.pop(0) + else: + child = Node(val, []) + top.children.append(child) + arr.append(child) + + return first + + +def parseSpecialParameter(index, paramType, param): + if paramType == "Node": + return parseNode(param) + return None diff --git a/src/debug/entry/python3/problems/843.js b/src/debug/entry/python3/problems/843.js new file mode 100644 index 00000000..a5774b09 --- /dev/null +++ b/src/debug/entry/python3/problems/843.js @@ -0,0 +1,26 @@ +function runUserScript(userFunm, params, paramTypes) { + if (params.length !== 3) { + onParameterError(); + } + function Master(secret, wordlist) { + this.guess = function (word) { + if (!wordlist.includes(word)) { + return -1; + } + + let match = 0; + for (let i = 0; i < word.length; i++) { + if (word[i] === secret[i]) { + match += 1; + } + }; + return match; + }; + }; + userFunm(params[1], new Master(params[0], params[1])); +} + + +function parseSpecialParameter(index, type, param) { + return null; +} diff --git a/src/debug/entry/python3/problems/common.py b/src/debug/entry/python3/problems/common.py new file mode 100644 index 00000000..2112df21 --- /dev/null +++ b/src/debug/entry/python3/problems/common.py @@ -0,0 +1,12 @@ +def runUserScript(func, params, paramTypes): + if (len(params) != len(paramTypes)): + onParameterError() + + newParams = [] + for i, val in enumerate(params): + newParams.append(parseParameter(i, paramTypes[i], val)) + func(*newParams) + + +def parseSpecialParameter(index, type, param): + return None diff --git a/src/debug/problemTypes.ts b/src/debug/problemTypes.ts new file mode 100644 index 00000000..f1cc0859 --- /dev/null +++ b/src/debug/problemTypes.ts @@ -0,0 +1,5318 @@ +export default { + 1: { + funName: "twoSum", + paramTypes: ["number[]", "number"], + returnType: "number[]", + testCase: "[2,7,11,15]\\n9", + }, + 2: { + funName: "addTwoNumbers", + paramTypes: ["ListNode", "ListNode"], + returnType: "ListNode", + testCase: "[2,4,3]\\n[5,6,4]", + }, + 3: { + funName: "lengthOfLongestSubstring", + paramTypes: ["string"], + returnType: "number", + testCase: '"abcabcbb"', + }, + 4: { + funName: "findMedianSortedArrays", + paramTypes: ["number[]", "number[]"], + returnType: "number", + testCase: "[1,3]\\n[2]", + }, + 5: { + funName: "longestPalindrome", + paramTypes: ["string"], + returnType: "string", + testCase: '"babad"', + }, + 6: { + funName: "convert", + paramTypes: ["string", "number"], + returnType: "string", + testCase: '"PAYPALISHIRING"\\n3', + }, + 7: { + funName: "reverse", + paramTypes: ["number"], + returnType: "number", + testCase: "123", + }, + 8: { + funName: "myAtoi", + paramTypes: ["string"], + returnType: "number", + testCase: '"42"', + }, + 9: { + funName: "isPalindrome", + paramTypes: ["number"], + returnType: "boolean", + testCase: "121", + }, + 10: { + funName: "isMatch", + paramTypes: ["string", "string"], + returnType: "boolean", + testCase: '"aa"\\n"a"', + }, + 11: { + funName: "maxArea", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,8,6,2,5,4,8,3,7]", + }, + 12: { + funName: "intToRoman", + paramTypes: ["number"], + returnType: "string", + testCase: "3", + }, + 13: { + funName: "romanToInt", + paramTypes: ["string"], + returnType: "number", + testCase: '"III"', + }, + 14: { + funName: "longestCommonPrefix", + paramTypes: ["string[]"], + returnType: "string", + testCase: '["flower","flow","flight"]', + }, + 15: { + funName: "threeSum", + paramTypes: ["number[]"], + returnType: "number[][]", + testCase: "[-1,0,1,2,-1,-4]", + }, + 16: { + funName: "threeSumClosest", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[-1,2,1,-4]\\n1", + }, + 17: { + funName: "letterCombinations", + paramTypes: ["string"], + returnType: "string[]", + testCase: '"23"', + }, + 18: { + funName: "fourSum", + paramTypes: ["number[]", "number"], + returnType: "number[][]", + testCase: "[1,0,-1,0,-2,2]\\n0", + }, + 19: { + funName: "removeNthFromEnd", + paramTypes: ["ListNode", "number"], + returnType: "ListNode", + testCase: "[1,2,3,4,5]\\n2", + }, + 20: { + funName: "isValid", + paramTypes: ["string"], + returnType: "boolean", + testCase: '"()"', + }, + 21: { + funName: "mergeTwoLists", + paramTypes: ["ListNode", "ListNode"], + returnType: "ListNode", + testCase: "[1,2,4]\\n[1,3,4]", + }, + 22: { + funName: "generateParenthesis", + paramTypes: ["number"], + returnType: "string[]", + testCase: "3", + }, + 23: { + funName: "mergeKLists", + paramTypes: ["ListNode[]"], + returnType: "ListNode", + testCase: "[[1,4,5],[1,3,4],[2,6]]", + }, + 24: { + funName: "swapPairs", + paramTypes: ["ListNode"], + returnType: "ListNode", + testCase: "[1,2,3,4]", + }, + 25: { + funName: "reverseKGroup", + paramTypes: ["ListNode", "number"], + returnType: "ListNode", + testCase: "[1,2,3,4,5]\\n2", + }, + 26: { + funName: "removeDuplicates", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,1,2]", + }, + 27: { + funName: "removeElement", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[3,2,2,3]\\n3", + }, + 28: { + funName: "strStr", + paramTypes: ["string", "string"], + returnType: "number", + testCase: '"hello"\\n"ll"', + }, + 29: { + funName: "divide", + paramTypes: ["number", "number"], + returnType: "number", + testCase: "10\\n3", + }, + 30: { + funName: "findSubstring", + paramTypes: ["string", "string[]"], + returnType: "number[]", + testCase: '"barfoothefoobarman"\\n["foo","bar"]', + }, + 31: { + funName: "nextPermutation", + paramTypes: ["number[]"], + returnType: "void", + testCase: "[1,2,3]", + }, + 32: { + funName: "longestValidParentheses", + paramTypes: ["string"], + returnType: "number", + testCase: '"(()"', + }, + 33: { + funName: "search", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[4,5,6,7,0,1,2]\\n0", + }, + 34: { + funName: "searchRange", + paramTypes: ["number[]", "number"], + returnType: "number[]", + testCase: "[5,7,7,8,8,10]\\n8", + }, + 35: { + funName: "searchInsert", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1,3,5,6]\\n5", + }, + 36: { + funName: "isValidSudoku", + paramTypes: ["character[][]"], + returnType: "boolean", + testCase: + '[["5","3",".",".","7",".",".",".","."],["6",".",".","1","9","5",".",".","."],[".","9","8",".",".",".",".","6","."],["8",".",".",".","6",".",".",".","3"],["4",".",".","8",".","3",".",".","1"],["7",".",".",".","2",".",".",".","6"],[".","6",".",".",".",".","2","8","."],[".",".",".","4","1","9",".",".","5"],[".",".",".",".","8",".",".","7","9"]]', + }, + 37: { + funName: "solveSudoku", + paramTypes: ["character[][]"], + returnType: "void", + testCase: + '[["5","3",".",".","7",".",".",".","."],["6",".",".","1","9","5",".",".","."],[".","9","8",".",".",".",".","6","."],["8",".",".",".","6",".",".",".","3"],["4",".",".","8",".","3",".",".","1"],["7",".",".",".","2",".",".",".","6"],[".","6",".",".",".",".","2","8","."],[".",".",".","4","1","9",".",".","5"],[".",".",".",".","8",".",".","7","9"]]', + }, + 38: { + funName: "countAndSay", + paramTypes: ["number"], + returnType: "string", + testCase: "1", + }, + 39: { + funName: "combinationSum", + paramTypes: ["number[]", "number"], + returnType: "number[][]", + testCase: "[2,3,6,7]\\n7", + }, + 40: { + funName: "combinationSum2", + paramTypes: ["number[]", "number"], + returnType: "number[][]", + testCase: "[10,1,2,7,6,1,5]\\n8", + }, + 41: { + funName: "firstMissingPositive", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,2,0]", + }, + 42: { + funName: "trap", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[0,1,0,2,1,0,1,3,2,1,2,1]", + }, + 43: { + funName: "multiply", + paramTypes: ["string", "string"], + returnType: "string", + testCase: '"2"\\n"3"', + }, + 44: { + funName: "isMatch", + paramTypes: ["string", "string"], + returnType: "boolean", + testCase: '"aa"\\n"a"', + }, + 45: { + funName: "jump", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[2,3,1,1,4]", + }, + 46: { + funName: "permute", + paramTypes: ["number[]"], + returnType: "number[][]", + testCase: "[1,2,3]", + }, + 47: { + funName: "permuteUnique", + paramTypes: ["number[]"], + returnType: "number[][]", + testCase: "[1,1,2]", + }, + 48: { + funName: "rotate", + paramTypes: ["number[][]"], + returnType: "void", + testCase: "[[1,2,3],[4,5,6],[7,8,9]]", + }, + 49: { + funName: "groupAnagrams", + paramTypes: ["string[]"], + returnType: "string[][]", + testCase: '["eat","tea","tan","ate","nat","bat"]', + }, + 50: { + funName: "myPow", + paramTypes: ["number", "number"], + returnType: "number", + testCase: "2.00000\\n10", + }, + 51: { + funName: "solveNQueens", + paramTypes: ["number"], + returnType: "string[][]", + testCase: "4", + }, + 52: { + funName: "totalNQueens", + paramTypes: ["number"], + returnType: "number", + testCase: "4", + }, + 53: { + funName: "maxSubArray", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[-2,1,-3,4,-1,2,1,-5,4]", + }, + 54: { + funName: "spiralOrder", + paramTypes: ["number[][]"], + returnType: "number[]", + testCase: "[[1,2,3],[4,5,6],[7,8,9]]", + }, + 55: { + funName: "canJump", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[2,3,1,1,4]", + }, + 56: { + funName: "merge", + paramTypes: ["number[][]"], + returnType: "number[][]", + testCase: "[[1,3],[2,6],[8,10],[15,18]]", + }, + 57: { + funName: "insert", + paramTypes: ["number[][]", "number[]"], + returnType: "number[][]", + testCase: "[[1,3],[6,9]]\\n[2,5]", + }, + 58: { + funName: "lengthOfLastWord", + paramTypes: ["string"], + returnType: "number", + testCase: '"Hello World"', + }, + 59: { + funName: "generateMatrix", + paramTypes: ["number"], + returnType: "number[][]", + testCase: "3", + }, + 60: { + funName: "getPermutation", + paramTypes: ["number", "number"], + returnType: "string", + testCase: "3\\n3", + }, + 61: { + funName: "rotateRight", + paramTypes: ["ListNode", "number"], + returnType: "ListNode", + testCase: "[1,2,3,4,5]\\n2", + }, + 62: { + funName: "uniquePaths", + paramTypes: ["number", "number"], + returnType: "number", + testCase: "3\\n2", + }, + 63: { + funName: "uniquePathsWithObstacles", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[0,0,0],[0,1,0],[0,0,0]]", + }, + 64: { + funName: "minPathSum", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[1,3,1],[1,5,1],[4,2,1]]", + }, + 65: { + funName: "isNumber", + paramTypes: ["string"], + returnType: "boolean", + testCase: '"0"', + }, + 66: { + funName: "plusOne", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[1,2,3]", + }, + 67: { + funName: "addBinary", + paramTypes: ["string", "string"], + returnType: "string", + testCase: '"11"\\n"1"', + }, + 68: { + funName: "fullJustify", + paramTypes: ["string[]", "number"], + returnType: "string[]", + testCase: '["This", "is", "an", "example", "of", "text", "justification."]\\n16', + }, + 69: { + funName: "mySqrt", + paramTypes: ["number"], + returnType: "number", + testCase: "4", + }, + 70: { + funName: "climbStairs", + paramTypes: ["number"], + returnType: "number", + testCase: "2", + }, + 71: { + funName: "simplifyPath", + paramTypes: ["string"], + returnType: "string", + testCase: '"/home/"', + }, + 72: { + funName: "minDistance", + paramTypes: ["string", "string"], + returnType: "number", + testCase: '"horse"\\n"ros"', + }, + 73: { + funName: "setZeroes", + paramTypes: ["number[][]"], + returnType: "void", + testCase: "[[1,1,1],[1,0,1],[1,1,1]]", + }, + 74: { + funName: "searchMatrix", + paramTypes: ["number[][]", "number"], + returnType: "boolean", + testCase: "[[1,3,5,7],[10,11,16,20],[23,30,34,50]]\\n3", + }, + 75: { + funName: "sortColors", + paramTypes: ["number[]"], + returnType: "void", + testCase: "[2,0,2,1,1,0]", + }, + 76: { + funName: "minWindow", + paramTypes: ["string", "string"], + returnType: "string", + testCase: '"ADOBECODEBANC"\\n"ABC"', + }, + 77: { + funName: "combine", + paramTypes: ["number", "number"], + returnType: "number[][]", + testCase: "4\\n2", + }, + 78: { + funName: "subsets", + paramTypes: ["number[]"], + returnType: "number[][]", + testCase: "[1,2,3]", + }, + 79: { + funName: "exist", + paramTypes: ["character[][]", "string"], + returnType: "boolean", + testCase: '[["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]]\\n"ABCCED"', + }, + 80: { + funName: "removeDuplicates", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,1,1,2,2,3]", + }, + 81: { + funName: "search", + paramTypes: ["number[]", "number"], + returnType: "boolean", + testCase: "[2,5,6,0,0,1,2]\\n0", + }, + 82: { + funName: "deleteDuplicates", + paramTypes: ["ListNode"], + returnType: "ListNode", + testCase: "[1,2,3,3,4,4,5]", + }, + 83: { + funName: "deleteDuplicates", + paramTypes: ["ListNode"], + returnType: "ListNode", + testCase: "[1,1,2]", + }, + 84: { + funName: "largestRectangleArea", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[2,1,5,6,2,3]", + }, + 85: { + funName: "maximalRectangle", + paramTypes: ["character[][]"], + returnType: "number", + testCase: '[["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]', + }, + 86: { + funName: "partition", + paramTypes: ["ListNode", "number"], + returnType: "ListNode", + testCase: "[1,4,3,2,5,2]\\n3", + }, + 87: { + funName: "isScramble", + paramTypes: ["string", "string"], + returnType: "boolean", + testCase: '"great"\\n"rgeat"', + }, + 88: { + funName: "merge", + paramTypes: ["number[]", "number", "number[]", "number"], + returnType: "void", + testCase: "[1,2,3,0,0,0]\\n3\\n[2,5,6]\\n3", + }, + 89: { + funName: "grayCode", + paramTypes: ["number"], + returnType: "number[]", + testCase: "2", + }, + 90: { + funName: "subsetsWithDup", + paramTypes: ["number[]"], + returnType: "number[][]", + testCase: "[1,2,2]", + }, + 91: { + funName: "numDecodings", + paramTypes: ["string"], + returnType: "number", + testCase: '"12"', + }, + 92: { + funName: "reverseBetween", + paramTypes: ["ListNode", "number", "number"], + returnType: "ListNode", + testCase: "[1,2,3,4,5]\\n2\\n4", + }, + 93: { + funName: "restoreIpAddresses", + paramTypes: ["string"], + returnType: "string[]", + testCase: '"25525511135"', + }, + 94: { + funName: "inorderTraversal", + paramTypes: ["TreeNode"], + returnType: "number[]", + testCase: "[1,null,2,3]", + }, + 95: { + funName: "generateTrees", + paramTypes: ["number"], + returnType: "TreeNode[]", + testCase: "3", + }, + 96: { + funName: "numTrees", + paramTypes: ["number"], + returnType: "number", + testCase: "3", + }, + 97: { + funName: "isInterleave", + paramTypes: ["string", "string", "string"], + returnType: "boolean", + testCase: '"aabcc"\\n"dbbca"\\n"aadbbcbcac"', + }, + 98: { + funName: "isValidBST", + paramTypes: ["TreeNode"], + returnType: "boolean", + testCase: "[2,1,3]", + }, + 99: { + funName: "recoverTree", + paramTypes: ["TreeNode"], + returnType: "void", + testCase: "[1,3,null,null,2]", + }, + 100: { + funName: "isSameTree", + paramTypes: ["TreeNode", "TreeNode"], + returnType: "boolean", + testCase: "[1,2,3]\\n[1,2,3]", + }, + 101: { + funName: "isSymmetric", + paramTypes: ["TreeNode"], + returnType: "boolean", + testCase: "[1,2,2,3,4,4,3]", + }, + 102: { + funName: "levelOrder", + paramTypes: ["TreeNode"], + returnType: "number[][]", + testCase: "[3,9,20,null,null,15,7]", + }, + 103: { + funName: "zigzagLevelOrder", + paramTypes: ["TreeNode"], + returnType: "number[][]", + testCase: "[3,9,20,null,null,15,7]", + }, + 104: { + funName: "maxDepth", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[3,9,20,null,null,15,7]", + }, + 105: { + funName: "buildTree", + paramTypes: ["number[]", "number[]"], + returnType: "TreeNode", + testCase: "[3,9,20,15,7]\\n[9,3,15,20,7]", + }, + 106: { + funName: "buildTree", + paramTypes: ["number[]", "number[]"], + returnType: "TreeNode", + testCase: "[9,3,15,20,7]\\n[9,15,7,20,3]", + }, + 107: { + funName: "levelOrderBottom", + paramTypes: ["TreeNode"], + returnType: "number[][]", + testCase: "[3,9,20,null,null,15,7]", + }, + 108: { + funName: "sortedArrayToBST", + paramTypes: ["number[]"], + returnType: "TreeNode", + testCase: "[-10,-3,0,5,9]", + }, + 109: { + funName: "sortedListToBST", + paramTypes: ["ListNode"], + returnType: "TreeNode", + testCase: "[-10,-3,0,5,9]", + }, + 110: { + funName: "isBalanced", + paramTypes: ["TreeNode"], + returnType: "boolean", + testCase: "[3,9,20,null,null,15,7]", + }, + 111: { + funName: "minDepth", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[3,9,20,null,null,15,7]", + }, + 112: { + funName: "hasPathSum", + paramTypes: ["TreeNode", "number"], + returnType: "boolean", + testCase: "[5,4,8,11,null,13,4,7,2,null,null,null,1]\\n22", + }, + 113: { + funName: "pathSum", + paramTypes: ["TreeNode", "number"], + returnType: "number[][]", + testCase: "[5,4,8,11,null,13,4,7,2,null,null,5,1]\\n22", + }, + 114: { + funName: "flatten", + paramTypes: ["TreeNode"], + returnType: "void", + testCase: "[1,2,5,3,4,null,6]", + }, + 115: { + funName: "numDistinct", + paramTypes: ["string", "string"], + returnType: "number", + testCase: '"rabbbit"\\n"rabbit"', + }, + 116: { + funName: "connect", + paramTypes: ["Node"], + returnType: "Node", + testCase: "[1,2,3,4,5,6,7]", + }, + 117: { + funName: "connect", + paramTypes: ["Node"], + returnType: "Node", + testCase: "[1,2,3,4,5,null,7]", + }, + 118: { + funName: "generate", + paramTypes: ["number"], + returnType: "number[][]", + testCase: "5", + }, + 119: { + funName: "getRow", + paramTypes: ["number"], + returnType: "number[]", + testCase: "3", + }, + 120: { + funName: "minimumTotal", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[2],[3,4],[6,5,7],[4,1,8,3]]", + }, + 121: { + funName: "maxProfit", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[7,1,5,3,6,4]", + }, + 122: { + funName: "maxProfit", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[7,1,5,3,6,4]", + }, + 123: { + funName: "maxProfit", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[3,3,5,0,0,3,1,4]", + }, + 124: { + funName: "maxPathSum", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[1,2,3]", + }, + 125: { + funName: "isPalindrome", + paramTypes: ["string"], + returnType: "boolean", + testCase: '"A man, a plan, a canal: Panama"', + }, + 126: { + funName: "findLadders", + paramTypes: ["string", "string", "string[]"], + returnType: "string[][]", + testCase: '"hit"\\n"cog"\\n["hot","dot","dog","lot","log","cog"]', + }, + 127: { + funName: "ladderLength", + paramTypes: ["string", "string", "string[]"], + returnType: "number", + testCase: '"hit"\\n"cog"\\n["hot","dot","dog","lot","log","cog"]', + }, + 128: { + funName: "longestConsecutive", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[100,4,200,1,3,2]", + }, + 129: { + funName: "sumNumbers", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[1,2,3]", + }, + 130: { + funName: "solve", + paramTypes: ["character[][]"], + returnType: "void", + testCase: '[["X","X","X","X"],["X","O","O","X"],["X","X","O","X"],["X","O","X","X"]]', + }, + 131: { + funName: "partition", + paramTypes: ["string"], + returnType: "string[][]", + testCase: '"aab"', + }, + 132: { + funName: "minCut", + paramTypes: ["string"], + returnType: "number", + testCase: '"aab"', + }, + 133: { + funName: "cloneGraph", + paramTypes: ["Node"], + returnType: "Node", + testCase: "[[2,4],[1,3],[2,4],[1,3]]", + }, + 134: { + funName: "canCompleteCircuit", + paramTypes: ["number[]", "number[]"], + returnType: "number", + testCase: "[1,2,3,4,5]\\n[3,4,5,1,2]", + }, + 135: { + funName: "candy", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,0,2]", + }, + 136: { + funName: "singleNumber", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[2,2,1]", + }, + 137: { + funName: "singleNumber", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[2,2,3,2]", + }, + 138: { + funName: "copyRandomList", + paramTypes: ["Node"], + returnType: "Node", + testCase: "[[7,null],[13,0],[11,4],[10,2],[1,0]]", + }, + 139: { + funName: "wordBreak", + paramTypes: ["string", "string[]"], + returnType: "boolean", + testCase: '"leetcode"\\n["leet","code"]', + }, + 140: { + funName: "wordBreak", + paramTypes: ["string", "string[]"], + returnType: "string[]", + testCase: '"catsanddog"\\n["cat","cats","and","sand","dog"]', + }, + 141: { + funName: "hasCycle", + paramTypes: ["ListNode"], + returnType: "boolean", + testCase: "[3,2,0,-4]\\n1", + }, + 142: { + funName: "detectCycle", + paramTypes: ["ListNode"], + returnType: "ListNode", + testCase: "[3,2,0,-4]\\n1", + }, + 143: { + funName: "reorderList", + paramTypes: ["ListNode"], + returnType: "void", + testCase: "[1,2,3,4]", + }, + 144: { + funName: "preorderTraversal", + paramTypes: ["TreeNode"], + returnType: "number[]", + testCase: "[1,null,2,3]", + }, + 145: { + funName: "postorderTraversal", + paramTypes: ["TreeNode"], + returnType: "number[]", + testCase: "[1,null,2,3]", + }, + 146: { + funName: "LRUCache", + paramTypes: ["number"], + returnType: "void", + testCase: + '["LRUCache","put","put","get","put","get","put","get","get","get"]\\n[[2],[1,1],[2,2],[1],[3,3],[2],[4,4],[1],[3],[4]]', + }, + 147: { + funName: "insertionSortList", + paramTypes: ["ListNode"], + returnType: "ListNode", + testCase: "[4,2,1,3]", + }, + 148: { + funName: "sortList", + paramTypes: ["ListNode"], + returnType: "ListNode", + testCase: "[4,2,1,3]", + }, + 149: { + funName: "maxPoints", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[1,1],[2,2],[3,3]]", + }, + 150: { + funName: "evalRPN", + paramTypes: ["string[]"], + returnType: "number", + testCase: '["2","1","+","3","*"]', + }, + 151: { + funName: "reverseWords", + paramTypes: ["string"], + returnType: "string", + testCase: '"the sky is blue"', + }, + 152: { + funName: "maxProduct", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[2,3,-2,4]", + }, + 153: { + funName: "findMin", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[3,4,5,1,2]", + }, + 154: { + funName: "findMin", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,3,5]", + }, + 155: { + funName: "MinStack", + paramTypes: [], + returnType: "void", + testCase: '["MinStack","push","push","push","getMin","pop","top","getMin"]\\n[[],[-2],[0],[-3],[],[],[],[]]', + }, + 160: { + funName: "getIntersectionNode", + paramTypes: ["ListNode", "ListNode"], + returnType: "ListNode", + testCase: "8\\n[4,1,8,4,5]\\n[5,0,1,8,4,5]\\n2\\n3", + }, + 162: { + funName: "findPeakElement", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,2,3,1]", + }, + 164: { + funName: "maximumGap", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[3,6,9,1]", + }, + 165: { + funName: "compareVersion", + paramTypes: ["string", "string"], + returnType: "number", + testCase: '"0.1"\\n"1.1"', + }, + 166: { + funName: "fractionToDecimal", + paramTypes: ["number", "number"], + returnType: "string", + testCase: "1\\n2", + }, + 167: { + funName: "twoSum", + paramTypes: ["number[]", "number"], + returnType: "number[]", + testCase: "[2,7,11,15]\\n9", + }, + 168: { + funName: "convertToTitle", + paramTypes: ["number"], + returnType: "string", + testCase: "1", + }, + 169: { + funName: "majorityElement", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[3,2,3]", + }, + 171: { + funName: "titleToNumber", + paramTypes: ["string"], + returnType: "number", + testCase: '"A"', + }, + 172: { + funName: "trailingZeroes", + paramTypes: ["number"], + returnType: "number", + testCase: "3", + }, + 173: { + funName: "BSTIterator", + paramTypes: ["TreeNode"], + returnType: "void", + testCase: + '["BSTIterator","next","next","hasNext","next","hasNext","next","hasNext","next","hasNext"]\\n[[[7,3,15,null,null,9,20]],[null],[null],[null],[null],[null],[null],[null],[null],[null]]', + }, + 174: { + funName: "calculateMinimumHP", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[-2,-3,3],[-5,-10,1],[10,30,-5]]", + }, + 179: { + funName: "largestNumber", + paramTypes: ["number[]"], + returnType: "string", + testCase: "[10,2]", + }, + 187: { + funName: "findRepeatedDnaSequences", + paramTypes: ["string"], + returnType: "string[]", + testCase: '"AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT"', + }, + 188: { + funName: "maxProfit", + paramTypes: ["number", "number[]"], + returnType: "number", + testCase: "2\\n[2,4,1]", + }, + 189: { + funName: "rotate", + paramTypes: ["number[]", "number"], + returnType: "void", + testCase: "[1,2,3,4,5,6,7]\\n3", + }, + 190: { + funName: "reverseBits", + paramTypes: ["number"], + returnType: "number", + testCase: "00000010100101000001111010011100", + }, + 191: { + funName: "hammingWeight", + paramTypes: ["number"], + returnType: "number", + testCase: "00000000000000000000000000001011", + }, + 198: { + funName: "rob", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,2,3,1]", + }, + 199: { + funName: "rightSideView", + paramTypes: ["TreeNode"], + returnType: "number[]", + testCase: "[1,2,3,null,5,null,4]", + }, + 200: { + funName: "numIslands", + paramTypes: ["character[][]"], + returnType: "number", + testCase: '[["1","1","1","1","0"],["1","1","0","1","0"],["1","1","0","0","0"],["0","0","0","0","0"]]', + }, + 201: { + funName: "rangeBitwiseAnd", + paramTypes: ["number", "number"], + returnType: "number", + testCase: "5\\n7", + }, + 202: { + funName: "isHappy", + paramTypes: ["number"], + returnType: "boolean", + testCase: "19", + }, + 203: { + funName: "removeElements", + paramTypes: ["ListNode", "number"], + returnType: "ListNode", + testCase: "[1,2,6,3,4,5,6]\\n6", + }, + 204: { + funName: "countPrimes", + paramTypes: ["number"], + returnType: "number", + testCase: "10", + }, + 205: { + funName: "isIsomorphic", + paramTypes: ["string", "string"], + returnType: "boolean", + testCase: '"egg"\\n"add"', + }, + 206: { + funName: "reverseList", + paramTypes: ["ListNode"], + returnType: "ListNode", + testCase: "[1,2,3,4,5]", + }, + 207: { + funName: "canFinish", + paramTypes: ["number", "number[][]"], + returnType: "boolean", + testCase: "2\\n[[1,0]]", + }, + 208: { + funName: "Trie", + paramTypes: [], + returnType: "void", + testCase: + '["Trie","insert","search","search","startsWith","insert","search"]\\n[[],["apple"],["apple"],["app"],["app"],["app"],["app"]]', + }, + 209: { + funName: "minSubArrayLen", + paramTypes: ["number", "number[]"], + returnType: "number", + testCase: "7\\n[2,3,1,2,4,3]", + }, + 210: { + funName: "findOrder", + paramTypes: ["number", "number[][]"], + returnType: "number[]", + testCase: "2\\n[[1,0]]", + }, + 211: { + funName: "WordDictionary", + paramTypes: [], + returnType: "void", + testCase: + '["WordDictionary","addWord","addWord","addWord","search","search","search","search"]\\n[[],["bad"],["dad"],["mad"],["pad"],["bad"],[".ad"],["b.."]]', + }, + 212: { + funName: "findWords", + paramTypes: ["character[][]", "string[]"], + returnType: "string[]", + testCase: + '[["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f","l","v"]]\\n["oath","pea","eat","rain"]', + }, + 213: { + funName: "rob", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[2,3,2]", + }, + 214: { + funName: "shortestPalindrome", + paramTypes: ["string"], + returnType: "string", + testCase: '"aacecaaa"', + }, + 215: { + funName: "findKthLargest", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[3,2,1,5,6,4]\\n2", + }, + 216: { + funName: "combinationSum3", + paramTypes: ["number", "number"], + returnType: "number[][]", + testCase: "3\\n7", + }, + 217: { + funName: "containsDuplicate", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[1,2,3,1]", + }, + 218: { + funName: "getSkyline", + paramTypes: ["number[][]"], + returnType: "number[][]", + testCase: "[[2,9,10],[3,7,15],[5,12,12],[15,20,10],[19,24,8]]", + }, + 219: { + funName: "containsNearbyDuplicate", + paramTypes: ["number[]", "number"], + returnType: "boolean", + testCase: "[1,2,3,1]\\n3", + }, + 220: { + funName: "containsNearbyAlmostDuplicate", + paramTypes: ["number[]", "number", "number"], + returnType: "boolean", + testCase: "[1,2,3,1]\\n3\\n0", + }, + 221: { + funName: "maximalSquare", + paramTypes: ["character[][]"], + returnType: "number", + testCase: '[["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]', + }, + 222: { + funName: "countNodes", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[1,2,3,4,5,6]", + }, + 223: { + funName: "computeArea", + paramTypes: ["number", "number", "number", "number", "number", "number", "number", "number"], + returnType: "number", + testCase: "-3\\n0\\n3\\n4\\n0\\n-1\\n9\\n2", + }, + 224: { + funName: "calculate", + paramTypes: ["string"], + returnType: "number", + testCase: '"1 + 1"', + }, + 225: { + funName: "MyStack", + paramTypes: [], + returnType: "void", + testCase: '["MyStack","push","push","top","pop","empty"]\\n[[],[1],[2],[],[],[]]', + }, + 226: { + funName: "invertTree", + paramTypes: ["TreeNode"], + returnType: "TreeNode", + testCase: "[4,2,7,1,3,6,9]", + }, + 227: { + funName: "calculate", + paramTypes: ["string"], + returnType: "number", + testCase: '"3+2*2"', + }, + 228: { + funName: "summaryRanges", + paramTypes: ["number[]"], + returnType: "string[]", + testCase: "[0,1,2,4,5,7]", + }, + 229: { + funName: "majorityElement", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[3,2,3]", + }, + 230: { + funName: "kthSmallest", + paramTypes: ["TreeNode", "number"], + returnType: "number", + testCase: "[3,1,4,null,2]\\n1", + }, + 231: { + funName: "isPowerOfTwo", + paramTypes: ["number"], + returnType: "boolean", + testCase: "1", + }, + 232: { + funName: "MyQueue", + paramTypes: [], + returnType: "void", + testCase: '["MyQueue","push","push","peek","pop","empty"]\\n[[],[1],[2],[],[],[]]', + }, + 233: { + funName: "countDigitOne", + paramTypes: ["number"], + returnType: "number", + testCase: "13", + }, + 234: { + funName: "isPalindrome", + paramTypes: ["ListNode"], + returnType: "boolean", + testCase: "[1,2]", + }, + 235: { + funName: "lowestCommonAncestor", + paramTypes: ["TreeNode", "TreeNode", "TreeNode"], + returnType: "TreeNode", + testCase: "[6,2,8,0,4,7,9,null,null,3,5]\\n2\\n8", + }, + 236: { + funName: "lowestCommonAncestor", + paramTypes: ["TreeNode", "TreeNode", "TreeNode"], + returnType: "TreeNode", + testCase: "[3,5,1,6,2,0,8,null,null,7,4]\\n5\\n1", + }, + 237: { + funName: "deleteNode", + paramTypes: ["ListNode"], + returnType: "void", + testCase: "[4,5,1,9]\\n5", + }, + 238: { + funName: "productExceptSelf", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[1,2,3,4]", + }, + 239: { + funName: "maxSlidingWindow", + paramTypes: ["number[]", "number"], + returnType: "number[]", + testCase: "[1,3,-1,-3,5,3,6,7]\\n3", + }, + 240: { + funName: "searchMatrix", + paramTypes: ["number[][]", "number"], + returnType: "boolean", + testCase: "[[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]]\\n5", + }, + 241: { + funName: "diffWaysToCompute", + paramTypes: ["string"], + returnType: "number[]", + testCase: '"2-1-1"', + }, + 242: { + funName: "isAnagram", + paramTypes: ["string", "string"], + returnType: "boolean", + testCase: '"anagram"\\n"nagaram"', + }, + 257: { + funName: "binaryTreePaths", + paramTypes: ["TreeNode"], + returnType: "string[]", + testCase: "[1,2,3,null,5]", + }, + 258: { + funName: "addDigits", + paramTypes: ["number"], + returnType: "number", + testCase: "38", + }, + 260: { + funName: "singleNumber", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[1,2,1,3,2,5]", + }, + 263: { + funName: "isUgly", + paramTypes: ["number"], + returnType: "boolean", + testCase: "6", + }, + 264: { + funName: "nthUglyNumber", + paramTypes: ["number"], + returnType: "number", + testCase: "10", + }, + 268: { + funName: "missingNumber", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[3,0,1]", + }, + 273: { + funName: "numberToWords", + paramTypes: ["number"], + returnType: "string", + testCase: "123", + }, + 274: { + funName: "hIndex", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[3,0,6,1,5]", + }, + 275: { + funName: "hIndex", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[0,1,3,5,6]", + }, + 278: { + funName: "firstBadVersion", + specialFunName: { + javascript: "solution", + }, + paramTypes: ["function"], + returnType: "function", + testCase: "5\\n4", + }, + 279: { + funName: "numSquares", + paramTypes: ["number"], + returnType: "number", + testCase: "12", + }, + 282: { + funName: "addOperators", + paramTypes: ["string", "number"], + returnType: "string[]", + testCase: '"123"\\n6', + }, + 283: { + funName: "moveZeroes", + paramTypes: ["number[]"], + returnType: "void", + testCase: "[0,1,0,3,12]", + }, + 287: { + funName: "findDuplicate", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,3,4,2,2]", + }, + 289: { + funName: "gameOfLife", + paramTypes: ["number[][]"], + returnType: "void", + testCase: "[[0,1,0],[0,0,1],[1,1,1],[0,0,0]]", + }, + 290: { + funName: "wordPattern", + paramTypes: ["string", "string"], + returnType: "boolean", + testCase: '"abba"\\n"dog cat cat dog"', + }, + 292: { + funName: "canWinNim", + paramTypes: ["number"], + returnType: "boolean", + testCase: "4", + }, + 295: { + funName: "MedianFinder", + paramTypes: [], + returnType: "void", + testCase: '["MedianFinder","addNum","addNum","findMedian","addNum","findMedian"]\\n[[],[1],[2],[],[3],[]]', + }, + 297: { + funName: "serialize", + paramTypes: ["TreeNode"], + returnType: "string", + testCase: "[1,2,3,null,null,4,5]", + }, + 299: { + funName: "getHint", + paramTypes: ["string", "string"], + returnType: "string", + testCase: '"1807"\\n"7810"', + }, + 300: { + funName: "lengthOfLIS", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[10,9,2,5,3,7,101,18]", + }, + 301: { + funName: "removeInvalidParentheses", + paramTypes: ["string"], + returnType: "string[]", + testCase: '"()())()"', + }, + 303: { + funName: "NumArray", + paramTypes: ["number[]"], + returnType: "void", + testCase: '["NumArray","sumRange","sumRange","sumRange"]\\n[[[-2,0,3,-5,2,-1]],[0,2],[2,5],[0,5]]', + }, + 304: { + funName: "NumMatrix", + paramTypes: ["number[][]"], + returnType: "void", + testCase: + '["NumMatrix","sumRegion","sumRegion","sumRegion"]\\n[[[[3,0,1,4,2],[5,6,3,2,1],[1,2,0,1,5],[4,1,0,1,7],[1,0,3,0,5]]],[2,1,4,3],[1,1,2,2],[1,2,2,4]]', + }, + 306: { + funName: "isAdditiveNumber", + paramTypes: ["string"], + returnType: "boolean", + testCase: '"112358"', + }, + 307: { + funName: "NumArray", + paramTypes: ["number[]"], + returnType: "void", + testCase: '["NumArray","sumRange","update","sumRange"]\\n[[[1,3,5]],[0,2],[1,2],[0,2]]', + }, + 309: { + funName: "maxProfit", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,2,3,0,2]", + }, + 310: { + funName: "findMinHeightTrees", + paramTypes: ["number", "number[][]"], + returnType: "number[]", + testCase: "4\\n[[1,0],[1,2],[1,3]]", + }, + 312: { + funName: "maxCoins", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[3,1,5,8]", + }, + 313: { + funName: "nthSuperUglyNumber", + paramTypes: ["number", "number[]"], + returnType: "number", + testCase: "12\\n[2,7,13,19]", + }, + 315: { + funName: "countSmaller", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[5,2,6,1]", + }, + 316: { + funName: "removeDuplicateLetters", + paramTypes: ["string"], + returnType: "string", + testCase: '"bcabc"', + }, + 318: { + funName: "maxProduct", + paramTypes: ["string[]"], + returnType: "number", + testCase: '["abcw","baz","foo","bar","xtfn","abcdef"]', + }, + 319: { + funName: "bulbSwitch", + paramTypes: ["number"], + returnType: "number", + testCase: "3", + }, + 321: { + funName: "maxNumber", + paramTypes: ["number[]", "number[]", "number"], + returnType: "number[]", + testCase: "[3,4,6,5]\\n[9,1,2,5,8,3]\\n5", + }, + 322: { + funName: "coinChange", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1,2,5]\\n11", + }, + 324: { + funName: "wiggleSort", + paramTypes: ["number[]"], + returnType: "void", + testCase: "[1,5,1,1,6,4]", + }, + 326: { + funName: "isPowerOfThree", + paramTypes: ["number"], + returnType: "boolean", + testCase: "27", + }, + 327: { + funName: "countRangeSum", + paramTypes: ["number[]", "number", "number"], + returnType: "number", + testCase: "[-2,5,-1]\\n-2\\n2", + }, + 328: { + funName: "oddEvenList", + paramTypes: ["ListNode"], + returnType: "ListNode", + testCase: "[1,2,3,4,5]", + }, + 329: { + funName: "longestIncreasingPath", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[9,9,4],[6,6,8],[2,1,1]]", + }, + 330: { + funName: "minPatches", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1,3]\\n6", + }, + 331: { + funName: "isValidSerialization", + paramTypes: ["string"], + returnType: "boolean", + testCase: '"9,3,4,#,#,1,#,#,2,#,6,#,#"', + }, + 332: { + funName: "findItinerary", + paramTypes: ["string[][]"], + returnType: "string[]", + testCase: '[["MUC","LHR"],["JFK","MUC"],["SFO","SJC"],["LHR","SFO"]]', + }, + 334: { + funName: "increasingTriplet", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[1,2,3,4,5]", + }, + 335: { + funName: "isSelfCrossing", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[2,1,1,2]", + }, + 336: { + funName: "palindromePairs", + paramTypes: ["string[]"], + returnType: "number[][]", + testCase: '["abcd","dcba","lls","s","sssll"]', + }, + 337: { + funName: "rob", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[3,2,3,null,3,null,1]", + }, + 338: { + funName: "countBits", + paramTypes: ["number"], + returnType: "number[]", + testCase: "2", + }, + 341: { + funName: "NestedIterator", + paramTypes: ["NestedInteger[]"], + returnType: "void", + testCase: "[[1,1],2,[1,1]]", + }, + 342: { + funName: "isPowerOfFour", + paramTypes: ["number"], + returnType: "boolean", + testCase: "16", + }, + 343: { + funName: "integerBreak", + paramTypes: ["number"], + returnType: "number", + testCase: "2", + }, + 344: { + funName: "reverseString", + paramTypes: ["character[]"], + returnType: "void", + testCase: '["h","e","l","l","o"]', + }, + 345: { + funName: "reverseVowels", + paramTypes: ["string"], + returnType: "string", + testCase: '"hello"', + }, + 347: { + funName: "topKFrequent", + paramTypes: ["number[]", "number"], + returnType: "number[]", + testCase: "[1,1,1,2,2,3]\\n2", + }, + 349: { + funName: "intersection", + paramTypes: ["number[]", "number[]"], + returnType: "number[]", + testCase: "[1,2,2,1]\\n[2,2]", + }, + 350: { + funName: "intersect", + paramTypes: ["number[]", "number[]"], + returnType: "number[]", + testCase: "[1,2,2,1]\\n[2,2]", + }, + 352: { + funName: "SummaryRanges", + paramTypes: [], + returnType: "void", + testCase: + '["SummaryRanges","addNum","getIntervals","addNum","getIntervals","addNum","getIntervals","addNum","getIntervals","addNum","getIntervals"]\\n[[],[1],[],[3],[],[7],[],[2],[],[6],[]]', + }, + 354: { + funName: "maxEnvelopes", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[5,4],[6,4],[6,7],[2,3]]", + }, + 355: { + funName: "Twitter", + paramTypes: [], + returnType: "void", + testCase: + '["Twitter","postTweet","getNewsFeed","follow","postTweet","getNewsFeed","unfollow","getNewsFeed"]\\n[[],[1,5],[1],[1,2],[2,6],[1],[1,2],[1]]', + }, + 357: { + funName: "countNumbersWithUniqueDigits", + paramTypes: ["number"], + returnType: "number", + testCase: "2", + }, + 363: { + funName: "maxSumSubmatrix", + paramTypes: ["number[][]", "number"], + returnType: "number", + testCase: "[[1,0,1],[0,-2,3]]\\n2", + }, + 365: { + funName: "canMeasureWater", + paramTypes: ["number", "number", "number"], + returnType: "boolean", + testCase: "3\\n5\\n4", + }, + 367: { + funName: "isPerfectSquare", + paramTypes: ["number"], + returnType: "boolean", + testCase: "16", + }, + 368: { + funName: "largestDivisibleSubset", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[1,2,3]", + }, + 371: { + funName: "getSum", + paramTypes: ["number", "number"], + returnType: "number", + testCase: "1\\n2", + }, + 372: { + funName: "superPow", + paramTypes: ["number", "number[]"], + returnType: "number", + testCase: "2\\n[3]", + }, + 373: { + funName: "kSmallestPairs", + paramTypes: ["number[]", "number[]", "number"], + returnType: "number[][]", + testCase: "[1,7,11]\\n[2,4,6]\\n3", + }, + 375: { + funName: "getMoneyAmount", + paramTypes: ["number"], + returnType: "number", + testCase: "1", + }, + 376: { + funName: "wiggleMaxLength", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,7,4,9,2,5]", + }, + 377: { + funName: "combinationSum4", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1,2,3]\\n4", + }, + 378: { + funName: "kthSmallest", + paramTypes: ["number[][]", "number"], + returnType: "number", + testCase: "[[1,5,9],[10,11,13],[12,13,15]]\\n8", + }, + 380: { + funName: "RandomizedSet", + paramTypes: [], + returnType: "void", + testCase: + '["RandomizedSet","insert","remove","insert","getRandom","remove","insert","getRandom"]\\n[[],[1],[2],[2],[],[1],[2],[]]', + }, + 381: { + funName: "RandomizedCollection", + paramTypes: [], + returnType: "void", + testCase: + '["RandomizedCollection","insert","insert","insert","getRandom","remove","getRandom"]\\n[[],[1],[1],[2],[],[1],[]]', + }, + 382: { + funName: "Solution", + paramTypes: ["ListNode"], + returnType: "void", + testCase: '["Solution","getRandom"]\\n[[[1,2,3]],[]]', + }, + 383: { + funName: "canConstruct", + paramTypes: ["string", "string"], + returnType: "boolean", + testCase: '"a"\\n"b"', + }, + 384: { + funName: "Solution", + paramTypes: ["number[]"], + returnType: "void", + testCase: '["Solution","shuffle","reset","shuffle"]\\n[[[1,2,3]],[],[],[]]', + }, + 385: { + funName: "deserialize", + paramTypes: ["string"], + returnType: "NestedInteger", + testCase: '"324"', + }, + 386: { + funName: "lexicalOrder", + paramTypes: ["number"], + returnType: "number[]", + testCase: "13", + }, + 387: { + funName: "firstUniqChar", + paramTypes: ["string"], + returnType: "number", + testCase: '"leetcode"', + }, + 388: { + funName: "lengthLongestPath", + paramTypes: ["string"], + returnType: "number", + testCase: '"dir\\\\n\\\\tsubdir1\\\\n\\\\tsubdir2\\\\n\\\\t\\\\tfile.ext"', + }, + 389: { + funName: "findTheDifference", + paramTypes: ["string", "string"], + returnType: "character", + testCase: '"abcd"\\n"abcde"', + }, + 390: { + funName: "lastRemaining", + paramTypes: ["number"], + returnType: "number", + testCase: "9", + }, + 391: { + funName: "isRectangleCover", + paramTypes: ["number[][]"], + returnType: "boolean", + testCase: "[[1,1,3,3],[3,1,4,2],[3,2,4,4],[1,3,2,4],[2,3,3,4]]", + }, + 392: { + funName: "isSubsequence", + paramTypes: ["string", "string"], + returnType: "boolean", + testCase: '"abc"\\n"ahbgdc"', + }, + 393: { + funName: "validUtf8", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[197,130,1]", + }, + 394: { + funName: "decodeString", + paramTypes: ["string"], + returnType: "string", + testCase: '"3[a]2[bc]"', + }, + 395: { + funName: "longestSubstring", + paramTypes: ["string", "number"], + returnType: "number", + testCase: '"aaabb"\\n3', + }, + 396: { + funName: "maxRotateFunction", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[]", + }, + 397: { + funName: "integerReplacement", + paramTypes: ["number"], + returnType: "number", + testCase: "8", + }, + 398: { + funName: "Solution", + paramTypes: ["number[]"], + returnType: "void", + testCase: '["Solution","pick"]\\n[[[1,2,3,3,3]],[3]]', + }, + 399: { + funName: "calcEquation", + paramTypes: ["string[][]", "number[]", "string[][]"], + returnType: "number[]", + testCase: '[["a","b"],["b","c"]]\\n[2.0,3.0]\\n[["a","c"],["b","a"],["a","e"],["a","a"],["x","x"]]', + }, + 400: { + funName: "findNthDigit", + paramTypes: ["number"], + returnType: "number", + testCase: "3", + }, + 401: { + funName: "readBinaryWatch", + paramTypes: ["number"], + returnType: "string[]", + testCase: "0", + }, + 402: { + funName: "removeKdigits", + paramTypes: ["string", "number"], + returnType: "string", + testCase: '"1432219"\\n3', + }, + 403: { + funName: "canCross", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[0,1,3,4,5,7,9,10,12]", + }, + 404: { + funName: "sumOfLeftLeaves", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[3,9,20,null,null,15,7]", + }, + 405: { + funName: "toHex", + paramTypes: ["number"], + returnType: "string", + testCase: "26", + }, + 406: { + funName: "reconstructQueue", + paramTypes: ["number[][]"], + returnType: "number[][]", + testCase: "[[7,0],[4,4],[7,1],[5,0],[6,1],[5,2]]", + }, + 407: { + funName: "trapRainWater", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[1,4,3,1,3,2],[3,2,1,3,2,4],[2,3,3,2,3,1]]", + }, + 409: { + funName: "longestPalindrome", + paramTypes: ["string"], + returnType: "number", + testCase: '"abccccdd"', + }, + 410: { + funName: "splitArray", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[7,2,5,10,8]\\n2", + }, + 412: { + funName: "fizzBuzz", + paramTypes: ["number"], + returnType: "string[]", + testCase: "1", + }, + 413: { + funName: "numberOfArithmeticSlices", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,2,3,4]", + }, + 414: { + funName: "thirdMax", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[3,2,1]", + }, + 415: { + funName: "addStrings", + paramTypes: ["string", "string"], + returnType: "string", + testCase: '"0"\\n"0"', + }, + 416: { + funName: "canPartition", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[1,5,11,5]", + }, + 417: { + funName: "pacificAtlantic", + paramTypes: ["number[][]"], + returnType: "number[][]", + testCase: "[[1,2,2,3,5],[3,2,3,4,4],[2,4,5,3,1],[6,7,1,4,5],[5,1,1,2,4]]", + }, + 419: { + funName: "countBattleships", + paramTypes: ["character[][]"], + returnType: "number", + testCase: '[["X",".",".","X"],[".",".",".","X"],[".",".",".","X"]]', + }, + 420: { + funName: "strongPasswordChecker", + paramTypes: ["string"], + returnType: "number", + testCase: '""', + }, + 421: { + funName: "findMaximumXOR", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[3,10,5,25,2,8]", + }, + 423: { + funName: "originalDigits", + paramTypes: ["string"], + returnType: "string", + testCase: '"owoztneoer"', + }, + 424: { + funName: "characterReplacement", + paramTypes: ["string", "number"], + returnType: "number", + testCase: '"ABAB"\\n2', + }, + 427: { + funName: "construct", + paramTypes: ["number[][]"], + returnType: "Node", + testCase: "[[0,1],[1,0]]", + }, + 429: { + funName: "levelOrder", + paramTypes: ["Node"], + returnType: "number[][]", + testCase: "[1,null,3,2,4,null,5,6]", + }, + // TODO: parse parameters + // 430: { + // funName: "flatten", + // paramTypes: ["Node"], + // returnType: "Node", + // testCase: "[1,2,3,4,5,6,null,null,null,7,8,9,10,null,null,11,12]", + // }, + 432: { + funName: "AllOne", + paramTypes: [], + returnType: "void", + testCase: '["AllOne","getMaxKey","getMinKey"]\\n[[],[],[]]', + }, + 433: { + funName: "minMutation", + paramTypes: ["string", "string", "string[]"], + returnType: "number", + testCase: '"AACCGGTT"\\n"AACCGGTA"\\n["AACCGGTA"]', + }, + 434: { + funName: "countSegments", + paramTypes: ["string"], + returnType: "number", + testCase: '"Hello, my name is John"', + }, + 435: { + funName: "eraseOverlapIntervals", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[1,2]]", + }, + 436: { + funName: "findRightInterval", + paramTypes: ["number[][]"], + returnType: "number[]", + testCase: "[[1,2]]", + }, + 437: { + funName: "pathSum", + paramTypes: ["TreeNode", "number"], + returnType: "number", + testCase: "[10,5,-3,3,2,null,11,3,-2,null,1]\\n8", + }, + 438: { + funName: "findAnagrams", + paramTypes: ["string", "string"], + returnType: "number[]", + testCase: '"cbaebabacd"\\n"abc"', + }, + 440: { + funName: "findKthNumber", + paramTypes: ["number", "number"], + returnType: "number", + testCase: "13\\n2", + }, + 441: { + funName: "arrangeCoins", + paramTypes: ["number"], + returnType: "number", + testCase: "5", + }, + 442: { + funName: "findDuplicates", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[4,3,2,7,8,2,3,1]", + }, + 443: { + funName: "compress", + paramTypes: ["character[]"], + returnType: "number", + testCase: '["a","a","b","b","c","c","c"]', + }, + 445: { + funName: "addTwoNumbers", + paramTypes: ["ListNode", "ListNode"], + returnType: "ListNode", + testCase: "[7,2,4,3]\\n[5,6,4]", + }, + 446: { + funName: "numberOfArithmeticSlices", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[2,4,6,8,10]", + }, + 447: { + funName: "numberOfBoomerangs", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[0,0],[1,0],[2,0]]", + }, + 448: { + funName: "findDisappearedNumbers", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[4,3,2,7,8,2,3,1]", + }, + 449: { + funName: "serialize", + paramTypes: ["TreeNode"], + returnType: "string", + testCase: "[2,1,3]", + }, + 450: { + funName: "deleteNode", + paramTypes: ["TreeNode", "number"], + returnType: "TreeNode", + testCase: "[5,3,6,2,4,null,7]\\n3", + }, + 451: { + funName: "frequencySort", + paramTypes: ["string"], + returnType: "string", + testCase: '"tree"', + }, + 452: { + funName: "findMinArrowShots", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[10,16],[2,8],[1,6],[7,12]]", + }, + 453: { + funName: "minMoves", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,2,3]", + }, + 454: { + funName: "fourSumCount", + paramTypes: ["number[]", "number[]", "number[]", "number[]"], + returnType: "number", + testCase: "[1,2]\\n[-2,-1]\\n[-1,2]\\n[0,2]", + }, + 455: { + funName: "findContentChildren", + paramTypes: ["number[]", "number[]"], + returnType: "number", + testCase: "[1,2,3]\\n[1,1]", + }, + 456: { + funName: "find132pattern", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[1,2,3,4]", + }, + 457: { + funName: "circularArrayLoop", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[2,-1,1,2,2]", + }, + 458: { + funName: "poorPigs", + paramTypes: ["number", "number", "number"], + returnType: "number", + testCase: "1000\\n15\\n60", + }, + 459: { + funName: "repeatedSubstringPattern", + paramTypes: ["string"], + returnType: "boolean", + testCase: '"abab"', + }, + 460: { + funName: "LFUCache", + paramTypes: ["number"], + returnType: "void", + testCase: + '["LFUCache","put","put","get","put","get","get","put","get","get","get"]\\n[[2],[1,1],[2,2],[1],[3,3],[2],[3],[4,4],[1],[3],[4]]', + }, + 461: { + funName: "hammingDistance", + paramTypes: ["number", "number"], + returnType: "number", + testCase: "1\\n4", + }, + 462: { + funName: "minMoves2", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,2,3]", + }, + 463: { + funName: "islandPerimeter", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[0,1,0,0],[1,1,1,0],[0,1,0,0],[1,1,0,0]]", + }, + 464: { + funName: "canIWin", + paramTypes: ["number", "number"], + returnType: "boolean", + testCase: "10\\n11", + }, + 466: { + funName: "getMaxRepetitions", + paramTypes: ["string", "number", "string", "number"], + returnType: "number", + testCase: '"acb"\\n4\\n"ab"\\n2', + }, + 467: { + funName: "findSubstringInWraproundString", + paramTypes: ["string"], + returnType: "number", + testCase: '"a"', + }, + 468: { + funName: "validIPAddress", + paramTypes: ["string"], + returnType: "string", + testCase: '"172.16.254.1"', + }, + 470: { + funName: "rand10", + paramTypes: [], + returnType: "number", + testCase: "1", + }, + 472: { + funName: "findAllConcatenatedWordsInADict", + paramTypes: ["string[]"], + returnType: "string[]", + testCase: '["cat","cats","catsdogcats","dog","dogcatsdog","hippopotamuses","rat","ratcatdogcat"]', + }, + 473: { + funName: "makesquare", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[1,1,2,2,2]", + }, + 474: { + funName: "findMaxForm", + paramTypes: ["string[]", "number", "number"], + returnType: "number", + testCase: '["10","0001","111001","1","0"]\\n5\\n3', + }, + 475: { + funName: "findRadius", + paramTypes: ["number[]", "number[]"], + returnType: "number", + testCase: "[1,2,3]\\n[2]", + }, + 476: { + funName: "findComplement", + paramTypes: ["number"], + returnType: "number", + testCase: "5", + }, + 477: { + funName: "totalHammingDistance", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[4,14,2]", + }, + 478: { + funName: "Solution", + paramTypes: ["number", "number", "number"], + returnType: "void", + testCase: '["Solution", "randPoint", "randPoint", "randPoint"]\\n[[1.0, 0.0, 0.0], [], [], []]', + }, + 479: { + funName: "largestPalindrome", + paramTypes: ["number"], + returnType: "number", + testCase: "1", + }, + 480: { + funName: "medianSlidingWindow", + paramTypes: ["number[]", "number"], + returnType: "number[]", + testCase: "[1,3,-1,-3,5,3,6,7]\\n3", + }, + 481: { + funName: "magicalString", + paramTypes: ["number"], + returnType: "number", + testCase: "1", + }, + 482: { + funName: "licenseKeyFormatting", + paramTypes: ["string", "number"], + returnType: "string", + testCase: '"5F3Z-2e-9-w"\\n4', + }, + 483: { + funName: "smallestGoodBase", + paramTypes: ["string"], + returnType: "string", + testCase: '"13"', + }, + 485: { + funName: "findMaxConsecutiveOnes", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,0,1,1,0,1]", + }, + 486: { + funName: "PredictTheWinner", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[1,5,2]", + }, + 488: { + funName: "findMinStep", + paramTypes: ["string", "string"], + returnType: "number", + testCase: '"WRRBBW"\\n"RB"', + }, + 491: { + funName: "findSubsequences", + paramTypes: ["number[]"], + returnType: "number[][]", + testCase: "[4,6,7,7]", + }, + 492: { + funName: "constructRectangle", + paramTypes: ["number"], + returnType: "number[]", + testCase: "1", + }, + 493: { + funName: "reversePairs", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,3,2,3,1]", + }, + 494: { + funName: "findTargetSumWays", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1,1,1,1,1]\\n3", + }, + 495: { + funName: "findPoisonedDuration", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1,4]\\n2", + }, + 496: { + funName: "nextGreaterElement", + paramTypes: ["number[]", "number[]"], + returnType: "number[]", + testCase: "[4,1,2]\\n[1,3,4,2]", + }, + 497: { + funName: "Solution", + paramTypes: ["number[][]"], + returnType: "void", + testCase: '["Solution", "pick", "pick", "pick"]\\n[[[[1, 1, 5, 5]]], [], [], []]', + }, + 498: { + funName: "findDiagonalOrder", + paramTypes: ["number[][]"], + returnType: "number[]", + testCase: "[[1,2,3],[4,5,6],[7,8,9]]", + }, + 500: { + funName: "findWords", + paramTypes: ["string[]"], + returnType: "string[]", + testCase: '["Hello","Alaska","Dad","Peace"]', + }, + 501: { + funName: "findMode", + paramTypes: ["TreeNode"], + returnType: "number[]", + testCase: "[1,null,2,2]", + }, + 502: { + funName: "findMaximizedCapital", + paramTypes: ["number", "number", "number[]", "number[]"], + returnType: "number", + testCase: "2\\n0\\n[1,2,3]\\n[0,1,1]", + }, + 503: { + funName: "nextGreaterElements", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[1,2,1]", + }, + 504: { + funName: "convertToBase7", + paramTypes: ["number"], + returnType: "string", + testCase: "100", + }, + 506: { + funName: "findRelativeRanks", + paramTypes: ["number[]"], + returnType: "string[]", + testCase: "[5,4,3,2,1]", + }, + 507: { + funName: "checkPerfectNumber", + paramTypes: ["number"], + returnType: "boolean", + testCase: "28", + }, + 508: { + funName: "findFrequentTreeSum", + paramTypes: ["TreeNode"], + returnType: "number[]", + testCase: "[5,2,-3]", + }, + 509: { + funName: "fib", + paramTypes: ["number"], + returnType: "number", + testCase: "2", + }, + 513: { + funName: "findBottomLeftValue", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[2,1,3]", + }, + 514: { + funName: "findRotateSteps", + paramTypes: ["string", "string"], + returnType: "number", + testCase: '"godding"\\n"gd"', + }, + 515: { + funName: "largestValues", + paramTypes: ["TreeNode"], + returnType: "number[]", + testCase: "[1,3,2,5,3,null,9]", + }, + 516: { + funName: "longestPalindromeSubseq", + paramTypes: ["string"], + returnType: "number", + testCase: '"bbbab"', + }, + 517: { + funName: "findMinMoves", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,0,5]", + }, + 518: { + funName: "change", + paramTypes: ["number", "number[]"], + returnType: "number", + testCase: "5\\n[1,2,5]", + }, + 519: { + funName: "Solution", + paramTypes: ["number", "number"], + returnType: "void", + testCase: '["Solution", "flip", "flip", "flip", "flip"]\\n[[2, 2], [], [], [], []]', + }, + 520: { + funName: "detectCapitalUse", + paramTypes: ["string"], + returnType: "boolean", + testCase: '"USA"', + }, + 521: { + funName: "findLUSlength", + paramTypes: ["string", "string"], + returnType: "number", + testCase: '"aba"\\n"cdc"', + }, + 522: { + funName: "findLUSlength", + paramTypes: ["string[]"], + returnType: "number", + testCase: '["aba","cdc","eae"]', + }, + 523: { + funName: "checkSubarraySum", + paramTypes: ["number[]", "number"], + returnType: "boolean", + testCase: "[23,2,4,6,7]\\n6", + }, + 524: { + funName: "findLongestWord", + paramTypes: ["string", "string[]"], + returnType: "string", + testCase: '"abpcplea"\\n["ale","apple","monkey","plea"]', + }, + 525: { + funName: "findMaxLength", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[0,1]", + }, + 526: { + funName: "countArrangement", + paramTypes: ["number"], + returnType: "number", + testCase: "2", + }, + 528: { + funName: "Solution", + paramTypes: ["number[]"], + returnType: "void", + testCase: '["Solution", "pickIndex"]\\n[[[1]], []]', + }, + 529: { + funName: "updateBoard", + paramTypes: ["character[][]", "number[]"], + returnType: "character[][]", + testCase: '[["E","E","E","E","E"],["E","E","M","E","E"],["E","E","E","E","E"],["E","E","E","E","E"]]\\n[3,0]', + }, + 530: { + funName: "getMinimumDifference", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[1,null,3,2]", + }, + 532: { + funName: "findPairs", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[3,1,4,1,5]\\n2", + }, + 535: { + funName: "encode", + paramTypes: ["string"], + returnType: "string", + testCase: '"https://leetcode.com/problems/design-tinyurl"', + }, + 537: { + funName: "complexNumberMultiply", + paramTypes: ["string", "string"], + returnType: "string", + testCase: '"1+1i"\\n"1+1i"', + }, + 538: { + funName: "convertBST", + paramTypes: ["TreeNode"], + returnType: "TreeNode", + testCase: "[5,2,13]", + }, + 539: { + funName: "findMinDifference", + paramTypes: ["string[]"], + returnType: "number", + testCase: '["23:59","00:00"]', + }, + 540: { + funName: "singleNonDuplicate", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,1,2,3,3,4,4,8,8]", + }, + 541: { + funName: "reverseStr", + paramTypes: ["string", "number"], + returnType: "string", + testCase: '"abcdefg"\\n2', + }, + 542: { + funName: "updateMatrix", + paramTypes: ["number[][]"], + returnType: "number[][]", + testCase: "[[0,0,0],[0,1,0],[0,0,0]]", + }, + 543: { + funName: "diameterOfBinaryTree", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[1,2,3,4,5]", + }, + 546: { + funName: "removeBoxes", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,3,2,2,2,3,4,3,1]", + }, + 547: { + funName: "findCircleNum", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[1,1,0],[1,1,0],[0,0,1]]", + }, + 551: { + funName: "checkRecord", + paramTypes: ["string"], + returnType: "boolean", + testCase: '"PPALLP"', + }, + 552: { + funName: "checkRecord", + paramTypes: ["number"], + returnType: "number", + testCase: "1", + }, + 553: { + funName: "optimalDivision", + paramTypes: ["number[]"], + returnType: "string", + testCase: "[1000,100,10,2]", + }, + 554: { + funName: "leastBricks", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[1,2,2,1],[3,1,2],[1,3,2],[2,4],[3,1,2],[1,3,1,1]]", + }, + 556: { + funName: "nextGreaterElement", + paramTypes: ["number"], + returnType: "number", + testCase: "12", + }, + 557: { + funName: "reverseWords", + paramTypes: ["string"], + returnType: "string", + testCase: '"Let\\', + }, + // TODO: parse parameters + // 558: { + // funName: "intersect", + // paramTypes: ["Node", "Node"], + // returnType: "Node", + // testCase: + // "[[0,1],[1,1],[1,1],[1,0],[1,0]]\\n[[0,1],[1,1],[0,1],[1,1],[1,0],null,null,null,null,[1,0],[1,0],[1,1],[1,1]]", + // }, + 559: { + funName: "maxDepth", + paramTypes: ["Node"], + returnType: "number", + testCase: "[1,null,3,2,4,null,5,6]", + }, + 560: { + funName: "subarraySum", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1,1,1]\\n2", + }, + 561: { + funName: "arrayPairSum", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,4,3,2]", + }, + 563: { + funName: "findTilt", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[1,2,3]", + }, + 564: { + funName: "nearestPalindromic", + paramTypes: ["string"], + returnType: "string", + testCase: '"1"', + }, + 565: { + funName: "arrayNesting", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[5,4,0,3,1,6,2]", + }, + 566: { + funName: "matrixReshape", + paramTypes: ["number[][]", "number", "number"], + returnType: "number[][]", + testCase: "[[1,2],[3,4]]\\n1\\n4", + }, + 567: { + funName: "checkInclusion", + paramTypes: ["string", "string"], + returnType: "boolean", + testCase: '"ab"\\n"eidbaooo"', + }, + 572: { + funName: "isSubtree", + paramTypes: ["TreeNode", "TreeNode"], + returnType: "boolean", + testCase: "[3,4,5,1,2]\\n[4,1,2]", + }, + 575: { + funName: "distributeCandies", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,1,2,2,3,3]", + }, + 576: { + funName: "findPaths", + paramTypes: ["number", "number", "number", "number", "number"], + returnType: "number", + testCase: "2\\n2\\n2\\n0\\n0", + }, + 581: { + funName: "findUnsortedSubarray", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[2,6,4,8,10,9,15]", + }, + 583: { + funName: "minDistance", + paramTypes: ["string", "string"], + returnType: "number", + testCase: '"sea"\\n"eat"', + }, + 587: { + funName: "outerTrees", + paramTypes: ["number[][]"], + returnType: "number[][]", + testCase: "[[1,1],[2,2],[2,0],[2,4],[3,3],[4,2]]", + }, + 589: { + funName: "preorder", + paramTypes: ["Node"], + returnType: "number[]", + testCase: "[1,null,3,2,4,null,5,6]", + }, + 590: { + funName: "postorder", + paramTypes: ["Node"], + returnType: "number[]", + testCase: "[1,null,3,2,4,null,5,6]", + }, + 591: { + funName: "isValid", + paramTypes: ["string"], + returnType: "boolean", + testCase: '"

This is the first line ]]>
"', + }, + 592: { + funName: "fractionAddition", + paramTypes: ["string"], + returnType: "string", + testCase: '"-1/2+1/2"', + }, + 593: { + funName: "validSquare", + paramTypes: ["number[]", "number[]", "number[]", "number[]"], + returnType: "boolean", + testCase: "[0,0]\\n[1,1]\\n[1,0]\\n[0,1]", + }, + 594: { + funName: "findLHS", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,3,2,2,5,2,3,7]", + }, + 598: { + funName: "maxCount", + paramTypes: ["number", "number", "number[][]"], + returnType: "number", + testCase: "3\\n3\\n[[2,2],[3,3]]", + }, + 599: { + funName: "findRestaurant", + paramTypes: ["string[]", "string[]"], + returnType: "string[]", + testCase: + '["Shogun","Tapioca Express","Burger King","KFC"]\\n["Piatti","The Grill at Torrey Pines","Hungry Hunter Steakhouse","Shogun"]', + }, + 600: { + funName: "findIntegers", + paramTypes: ["number"], + returnType: "number", + testCase: "1", + }, + 605: { + funName: "canPlaceFlowers", + paramTypes: ["number[]", "number"], + returnType: "boolean", + testCase: "[1,0,0,0,1]\\n1", + }, + 606: { + funName: "tree2str", + paramTypes: ["TreeNode"], + returnType: "string", + testCase: "[1,2,3,4]", + }, + 609: { + funName: "findDuplicate", + paramTypes: ["string[]"], + returnType: "string[][]", + testCase: '["root/a 1.txt(abcd) 2.txt(efgh)","root/c 3.txt(abcd)","root/c/d 4.txt(efgh)","root 4.txt(efgh)"]', + }, + 611: { + funName: "triangleNumber", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[2,2,3,4]", + }, + 617: { + funName: "mergeTrees", + paramTypes: ["TreeNode", "TreeNode"], + returnType: "TreeNode", + testCase: "[1,3,2,5]\\n[2,1,3,null,4,null,7]", + }, + 621: { + funName: "leastInterval", + paramTypes: ["character[]", "number"], + returnType: "number", + testCase: '["A","A","A","B","B","B"]\\n2', + }, + 622: { + funName: "MyCircularQueue", + paramTypes: ["number"], + returnType: "void", + testCase: + '["MyCircularQueue","enQueue","enQueue","enQueue","enQueue","Rear","isFull","deQueue","enQueue","Rear"]\\n[[3],[1],[2],[3],[4],[],[],[],[4],[]]', + }, + 623: { + funName: "addOneRow", + paramTypes: ["TreeNode", "number", "number"], + returnType: "TreeNode", + testCase: "[4,2,6,3,1,5]\\n1\\n2", + }, + 628: { + funName: "maximumProduct", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,2,3]", + }, + 629: { + funName: "kInversePairs", + paramTypes: ["number", "number"], + returnType: "number", + testCase: "3\\n0", + }, + 630: { + funName: "scheduleCourse", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[100,200],[200,1300],[1000,1250],[2000,3200]]", + }, + 632: { + funName: "smallestRange", + paramTypes: ["number[][]"], + returnType: "number[]", + testCase: "[[4,10,15,24,26],[0,9,12,20],[5,18,22,30]]", + }, + 633: { + funName: "judgeSquareSum", + paramTypes: ["number"], + returnType: "boolean", + testCase: "5", + }, + 636: { + funName: "exclusiveTime", + paramTypes: ["number", "string[]"], + returnType: "number[]", + testCase: '2\\n["0:start:0","1:start:2","1:end:5","0:end:6"]', + }, + 637: { + funName: "averageOfLevels", + paramTypes: ["TreeNode"], + returnType: "number[]", + testCase: "[3,9,20,15,7]", + }, + 638: { + funName: "shoppingOffers", + paramTypes: ["number[]", "number[][]", "number[]"], + returnType: "number", + testCase: "[2,5]\\n[[3,0,5],[1,2,10]]\\n[3,2]", + }, + 639: { + funName: "numDecodings", + paramTypes: ["string"], + returnType: "number", + testCase: '"*"', + }, + 640: { + funName: "solveEquation", + paramTypes: ["string"], + returnType: "string", + testCase: '"x+5-3+x=6+x-2"', + }, + 641: { + funName: "MyCircularDeque", + paramTypes: ["number"], + returnType: "void", + testCase: + '["MyCircularDeque","insertLast","insertLast","insertFront","insertFront","getRear","isFull","deleteLast","insertFront","getFront"]\\n[[3],[1],[2],[3],[4],[],[],[],[4],[]]', + }, + 643: { + funName: "findMaxAverage", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1,12,-5,-6,50,3]\\n4", + }, + 645: { + funName: "findErrorNums", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[1,2,2,4]", + }, + 646: { + funName: "findLongestChain", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[1,2], [2,3], [3,4]]", + }, + 647: { + funName: "countSubstrings", + paramTypes: ["string"], + returnType: "number", + testCase: '"abc"', + }, + 648: { + funName: "replaceWords", + paramTypes: ["string[]", "string"], + returnType: "string", + testCase: '["cat", "bat", "rat"]\\n"the cattle was rattled by the battery"', + }, + 649: { + funName: "predictPartyVictory", + paramTypes: ["string"], + returnType: "string", + testCase: '"RD"', + }, + 650: { + funName: "minSteps", + paramTypes: ["number"], + returnType: "number", + testCase: "3", + }, + 652: { + funName: "findDuplicateSubtrees", + paramTypes: ["TreeNode"], + returnType: "TreeNode[]", + testCase: "[1,2,3,4,null,2,4,null,null,4]", + }, + 653: { + funName: "findTarget", + paramTypes: ["TreeNode", "number"], + returnType: "boolean", + testCase: "[5,3,6,2,4,null,7]\\n9", + }, + 654: { + funName: "constructMaximumBinaryTree", + paramTypes: ["number[]"], + returnType: "TreeNode", + testCase: "[3,2,1,6,0,5]", + }, + 655: { + funName: "printTree", + paramTypes: ["TreeNode"], + returnType: "string[][]", + testCase: "[1,2]", + }, + 657: { + funName: "judgeCircle", + paramTypes: ["string"], + returnType: "boolean", + testCase: '"UD"', + }, + 658: { + funName: "findClosestElements", + paramTypes: ["number[]", "number", "number"], + returnType: "number[]", + testCase: "[1,2,3,4,5]\\n4\\n3", + }, + 659: { + funName: "isPossible", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[1,2,3,3,4,5]", + }, + 661: { + funName: "imageSmoother", + paramTypes: ["number[][]"], + returnType: "number[][]", + testCase: "[[1,1,1],[1,0,1],[1,1,1]]", + }, + 662: { + funName: "widthOfBinaryTree", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[1,3,2,5,3,null,9]", + }, + 664: { + funName: "strangePrinter", + paramTypes: ["string"], + returnType: "number", + testCase: '"aaabbb"', + }, + 665: { + funName: "checkPossibility", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[4,2,3]", + }, + 667: { + funName: "constructArray", + paramTypes: ["number", "number"], + returnType: "number[]", + testCase: "3\\n2", + }, + 668: { + funName: "findKthNumber", + paramTypes: ["number", "number", "number"], + returnType: "number", + testCase: "3\\n3\\n5", + }, + 669: { + funName: "trimBST", + paramTypes: ["TreeNode", "number", "number"], + returnType: "TreeNode", + testCase: "[1,0,2]\\n1\\n2", + }, + 670: { + funName: "maximumSwap", + paramTypes: ["number"], + returnType: "number", + testCase: "2736", + }, + 671: { + funName: "findSecondMinimumValue", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[2,2,5,null,null,5,7]", + }, + 672: { + funName: "flipLights", + paramTypes: ["number", "number"], + returnType: "number", + testCase: "1\\n1", + }, + 673: { + funName: "findNumberOfLIS", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,3,5,4,7]", + }, + 674: { + funName: "findLengthOfLCIS", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,3,5,4,7]", + }, + 675: { + funName: "cutOffTree", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[1,2,3],[0,0,4],[7,6,5]]", + }, + 676: { + funName: "MagicDictionary", + paramTypes: [], + returnType: "void", + testCase: + '["MagicDictionary", "buildDict", "search", "search", "search", "search"]\\n[[], [["hello","leetcode"]], ["hello"], ["hhllo"], ["hell"], ["leetcoded"]]', + }, + 677: { + funName: "MapSum", + paramTypes: [], + returnType: "void", + testCase: '["MapSum", "insert", "sum", "insert", "sum"]\\n[[], ["apple",3], ["ap"], ["app",2], ["ap"]]', + }, + 678: { + funName: "checkValidString", + paramTypes: ["string"], + returnType: "boolean", + testCase: '"()"', + }, + 679: { + funName: "judgePoint24", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[4,1,8,7]", + }, + 680: { + funName: "validPalindrome", + paramTypes: ["string"], + returnType: "boolean", + testCase: '"aba"', + }, + 682: { + funName: "calPoints", + paramTypes: ["string[]"], + returnType: "number", + testCase: '["5","2","C","D","+"]', + }, + 684: { + funName: "findRedundantConnection", + paramTypes: ["number[][]"], + returnType: "number[]", + testCase: "[[1,2],[1,3],[2,3]]", + }, + 685: { + funName: "findRedundantDirectedConnection", + paramTypes: ["number[][]"], + returnType: "number[]", + testCase: "[[1,2],[1,3],[2,3]]", + }, + 686: { + funName: "repeatedStringMatch", + paramTypes: ["string", "string"], + returnType: "number", + testCase: '"abcd"\\n"cdabcdab"', + }, + 687: { + funName: "longestUnivaluePath", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[5,4,5,1,1,5]", + }, + 688: { + funName: "knightProbability", + paramTypes: ["number", "number", "number", "number"], + returnType: "number", + testCase: "3\\n2\\n0\\n0", + }, + 689: { + funName: "maxSumOfThreeSubarrays", + paramTypes: ["number[]", "number"], + returnType: "number[]", + testCase: "[1,2,1,2,6,7,5,1]\\n2", + }, + 691: { + funName: "minStickers", + paramTypes: ["string[]", "string"], + returnType: "number", + testCase: '["with","example","science"]\\n"thehat"', + }, + 692: { + funName: "topKFrequent", + paramTypes: ["string[]", "number"], + returnType: "string[]", + testCase: '["i", "love", "leetcode", "i", "love", "coding"]\\n2', + }, + 693: { + funName: "hasAlternatingBits", + paramTypes: ["number"], + returnType: "boolean", + testCase: "5", + }, + 695: { + funName: "maxAreaOfIsland", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[1,1,0,0,0],[1,1,0,0,0],[0,0,0,1,1],[0,0,0,1,1]]", + }, + 696: { + funName: "countBinarySubstrings", + paramTypes: ["string"], + returnType: "number", + testCase: '"00110"', + }, + 697: { + funName: "findShortestSubArray", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,2,2,3,1]", + }, + 698: { + funName: "canPartitionKSubsets", + paramTypes: ["number[]", "number"], + returnType: "boolean", + testCase: "[4,3,2,3,5,2,1]\\n4", + }, + 699: { + funName: "fallingSquares", + paramTypes: ["number[][]"], + returnType: "number[]", + testCase: "[[1,2],[2,3],[6,1]]", + }, + 700: { + funName: "searchBST", + paramTypes: ["TreeNode", "number"], + returnType: "TreeNode", + testCase: "[4,2,7,1,3]\\n2", + }, + 701: { + funName: "insertIntoBST", + paramTypes: ["TreeNode", "number"], + returnType: "TreeNode", + testCase: "[4,2,7,1,3]\\n5", + }, + 703: { + funName: "KthLargest", + paramTypes: ["number", "number[]"], + returnType: "void", + testCase: '["KthLargest","add","add","add","add","add"]\\n[[3,[4,5,8,2]],[3],[5],[10],[9],[4]]', + }, + 704: { + funName: "search", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[-1,0,3,5,9,12]\\n9", + }, + 705: { + funName: "MyHashSet", + paramTypes: [], + returnType: "void", + testCase: + '["MyHashSet","add","add","contains","contains","add","contains","remove","contains"]\\n[[],[1],[2],[1],[3],[2],[2],[2],[2]]', + }, + 706: { + funName: "MyHashMap", + paramTypes: [], + returnType: "void", + testCase: + '["MyHashMap","put","put","get","get","put","get", "remove", "get"]\\n[[],[1,1],[2,2],[1],[3],[2,1],[2],[2],[2]]', + }, + 707: { + funName: "MyLinkedList", + paramTypes: [], + returnType: "void", + testCase: + '["MyLinkedList","addAtHead","addAtTail","addAtIndex","get","deleteAtIndex","get"]\\n[[],[1],[3],[1,2],[1],[1],[1]]', + }, + 709: { + funName: "toLowerCase", + paramTypes: ["string"], + returnType: "string", + testCase: '"Hello"', + }, + 710: { + funName: "Solution", + paramTypes: ["number", "number[]"], + returnType: "void", + testCase: '["Solution", "pick", "pick", "pick"]\\n[[1, []], [], [], []]', + }, + 712: { + funName: "minimumDeleteSum", + paramTypes: ["string", "string"], + returnType: "number", + testCase: '"sea"\\n"eat"', + }, + 713: { + funName: "numSubarrayProductLessThanK", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[10,5,2,6]\\n100", + }, + 714: { + funName: "maxProfit", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1,3,2,8,4,9]\\n2", + }, + 715: { + funName: "RangeModule", + paramTypes: [], + returnType: "void", + testCase: + '["RangeModule","addRange","removeRange","queryRange","queryRange","queryRange"]\\n[[],[10,20],[14,16],[10,14],[13,15],[16,17]]', + }, + 717: { + funName: "isOneBitCharacter", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[1,0,0]", + }, + 718: { + funName: "findLength", + paramTypes: ["number[]", "number[]"], + returnType: "number", + testCase: "[1,2,3,2,1]\\n[3,2,1,4,7]", + }, + 719: { + funName: "smallestDistancePair", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1,3,1]\\n1", + }, + 720: { + funName: "longestWord", + paramTypes: ["string[]"], + returnType: "string", + testCase: '["w","wo","wor","worl","world"]', + }, + 721: { + funName: "accountsMerge", + paramTypes: ["string[][]"], + returnType: "string[][]", + testCase: + '[["John","johnsmith@mail.com","john_newyork@mail.com"],["John","johnsmith@mail.com","john00@mail.com"],["Mary","mary@mail.com"],["John","johnnybravo@mail.com"]]', + }, + 722: { + funName: "removeComments", + paramTypes: ["string[]"], + returnType: "string[]", + testCase: + '["/*Test program */", "int main()", "{ ", " // variable declaration ", "int a, b, c;", "/* This is a test", " multiline ", " comment for ", " testing */", "a = b + c;", "}"]', + }, + 724: { + funName: "pivotIndex", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,7,3,6,5,6]", + }, + 725: { + funName: "splitListToParts", + paramTypes: ["ListNode", "number"], + returnType: "ListNode[]", + testCase: "[1,2,3,4]\\n5", + }, + 726: { + funName: "countOfAtoms", + paramTypes: ["string"], + returnType: "string", + testCase: '"H2O"', + }, + 728: { + funName: "selfDividingNumbers", + paramTypes: ["number", "number"], + returnType: "number[]", + testCase: "1\\n22", + }, + 729: { + funName: "MyCalendar", + paramTypes: [], + returnType: "void", + testCase: '["MyCalendar","book","book","book"]\\n[[],[10,20],[15,25],[20,30]]', + }, + 730: { + funName: "countPalindromicSubsequences", + paramTypes: ["string"], + returnType: "number", + testCase: '"bccb"', + }, + 731: { + funName: "MyCalendarTwo", + paramTypes: [], + returnType: "void", + testCase: + '["MyCalendarTwo","book","book","book","book","book","book"]\\n[[],[10,20],[50,60],[10,40],[5,15],[5,10],[25,55]]', + }, + 732: { + funName: "MyCalendarThree", + paramTypes: [], + returnType: "void", + testCase: + '["MyCalendarThree","book","book","book","book","book","book"]\\n[[],[10,20],[50,60],[10,40],[5,15],[5,10],[25,55]]', + }, + 733: { + funName: "floodFill", + paramTypes: ["number[][]", "number", "number", "number"], + returnType: "number[][]", + testCase: "[[1,1,1],[1,1,0],[1,0,1]]\\n1\\n1\\n2", + }, + 735: { + funName: "asteroidCollision", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[5,10,-5]", + }, + 736: { + funName: "evaluate", + paramTypes: ["string"], + returnType: "number", + testCase: '"(add 1 2)"', + }, + 738: { + funName: "monotoneIncreasingDigits", + paramTypes: ["number"], + returnType: "number", + testCase: "10", + }, + 739: { + funName: "dailyTemperatures", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[73,74,75,71,69,72,76,73]", + }, + 740: { + funName: "deleteAndEarn", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[3,4,2]", + }, + 741: { + funName: "cherryPickup", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[0,1,-1],[1,0,-1],[1,1,1]]", + }, + 743: { + funName: "networkDelayTime", + paramTypes: ["number[][]", "number", "number"], + returnType: "number", + testCase: "[[2,1,1],[2,3,1],[3,4,1]]\\n4\\n2", + }, + 744: { + funName: "nextGreatestLetter", + paramTypes: ["character[]", "character"], + returnType: "character", + testCase: '["c","f","j"]\\n"a"', + }, + 745: { + funName: "WordFilter", + paramTypes: ["string[]"], + returnType: "void", + testCase: '["WordFilter","f"]\\n[[["apple"]],["a","e"]]', + }, + 746: { + funName: "minCostClimbingStairs", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[0,0,0,0]", + }, + 747: { + funName: "dominantIndex", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[0,0,0,1]", + }, + 748: { + funName: "shortestCompletingWord", + paramTypes: ["string", "string[]"], + returnType: "string", + testCase: '"1s3 PSt"\\n["step","steps","stripe","stepple"]', + }, + 749: { + funName: "containVirus", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[0,1,0,0,0,0,0,1],[0,1,0,0,0,0,0,1],[0,0,0,0,0,0,0,1],[0,0,0,0,0,0,0,0]]", + }, + 752: { + funName: "openLock", + paramTypes: ["string[]", "string"], + returnType: "number", + testCase: '["0201","0101","0102","1212","2002"]\\n"0202"', + }, + 753: { + funName: "crackSafe", + paramTypes: ["number", "number"], + returnType: "string", + testCase: "1\\n1", + }, + 754: { + funName: "reachNumber", + paramTypes: ["number"], + returnType: "number", + testCase: "1", + }, + 756: { + funName: "pyramidTransition", + paramTypes: ["string", "string[]"], + returnType: "boolean", + testCase: '"ABC"\\n["ABD","BCE","DEF","FFF"]', + }, + 757: { + funName: "intersectionSizeTwo", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[1,3],[1,4],[2,5],[3,5]]", + }, + 761: { + funName: "makeLargestSpecial", + paramTypes: ["string"], + returnType: "string", + testCase: '"11011000"', + }, + 762: { + funName: "countPrimeSetBits", + paramTypes: ["number", "number"], + returnType: "number", + testCase: "842\\n888", + }, + 763: { + funName: "partitionLabels", + paramTypes: ["string"], + returnType: "number[]", + testCase: '"ababcbacadefegdehijhklij"', + }, + 764: { + funName: "orderOfLargestPlusSign", + paramTypes: ["number", "number[][]"], + returnType: "number", + testCase: "5\\n[[4,2]]", + }, + 765: { + funName: "minSwapsCouples", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[0,2,1,3]", + }, + 766: { + funName: "isToeplitzMatrix", + paramTypes: ["number[][]"], + returnType: "boolean", + testCase: "[[1,2,3,4],[5,1,2,3],[9,5,1,2]]", + }, + 767: { + funName: "reorganizeString", + paramTypes: ["string"], + returnType: "string", + testCase: '"aab"', + }, + 768: { + funName: "maxChunksToSorted", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[5,4,3,2,1]", + }, + 769: { + funName: "maxChunksToSorted", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[4,3,2,1,0]", + }, + 770: { + funName: "basicCalculatorIV", + paramTypes: ["string", "string[]", "number[]"], + returnType: "string[]", + testCase: '"e + 8 - a + 5"\\n["e"]\\n[1]', + }, + 771: { + funName: "numJewelsInStones", + paramTypes: ["string", "string"], + returnType: "number", + testCase: '"aA"\\n"aAAbbbb"', + }, + 773: { + funName: "slidingPuzzle", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[1,2,3],[4,0,5]]", + }, + 775: { + funName: "isIdealPermutation", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[0]", + }, + 777: { + funName: "canTransform", + paramTypes: ["string", "string"], + returnType: "boolean", + testCase: '"X"\\n"L"', + }, + 778: { + funName: "swimInWater", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[0,2],[1,3]]", + }, + 779: { + funName: "kthGrammar", + paramTypes: ["number", "number"], + returnType: "number", + testCase: "1\\n1", + }, + 780: { + funName: "reachingPoints", + paramTypes: ["number", "number", "number", "number"], + returnType: "boolean", + testCase: "9\\n5\\n12\\n8", + }, + 781: { + funName: "numRabbits", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,0,1,0,0]", + }, + 782: { + funName: "movesToChessboard", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[0,1,1,0],[0,1,1,0],[1,0,0,1],[1,0,0,1]]", + }, + 783: { + funName: "minDiffInBST", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[4,2,6,1,3,null,null]", + }, + 784: { + funName: "letterCasePermutation", + paramTypes: ["string"], + returnType: "string[]", + testCase: '"a1b2"', + }, + 785: { + funName: "isBipartite", + paramTypes: ["number[][]"], + returnType: "boolean", + testCase: "[[1,3],[0,2],[1,3],[0,2]]", + }, + 786: { + funName: "kthSmallestPrimeFraction", + paramTypes: ["number[]", "number"], + returnType: "number[]", + testCase: "[1,2,3,5]\\n3", + }, + 787: { + funName: "findCheapestPrice", + paramTypes: ["number", "number[][]", "number", "number", "number"], + returnType: "number", + testCase: "3\\n[[0,1,100],[1,2,100],[0,2,500]]\\n0\\n2\\n1", + }, + 788: { + funName: "rotatedDigits", + paramTypes: ["number"], + returnType: "number", + testCase: "10", + }, + 789: { + funName: "escapeGhosts", + paramTypes: ["number[][]", "number[]"], + returnType: "boolean", + testCase: "[[1,0],[0,3]]\\n[0,1]", + }, + 790: { + funName: "numTilings", + paramTypes: ["number"], + returnType: "number", + testCase: "3", + }, + 791: { + funName: "customSortString", + paramTypes: ["string", "string"], + returnType: "string", + testCase: '"cba"\\n"abcd"', + }, + 792: { + funName: "numMatchingSubseq", + paramTypes: ["string", "string[]"], + returnType: "number", + testCase: '"abcde"\\n["a","bb","acd","ace"]', + }, + 793: { + funName: "preimageSizeFZF", + paramTypes: ["number"], + returnType: "number", + testCase: "0", + }, + 794: { + funName: "validTicTacToe", + paramTypes: ["string[]"], + returnType: "boolean", + testCase: '["O "," "," "]', + }, + 795: { + funName: "numSubarrayBoundedMax", + paramTypes: ["number[]", "number", "number"], + returnType: "number", + testCase: "[2,1,4,3]\\n2\\n3", + }, + 796: { + funName: "rotateString", + paramTypes: ["string", "string"], + returnType: "boolean", + testCase: '"abcde"\\n"cdeab"', + }, + 797: { + funName: "allPathsSourceTarget", + paramTypes: ["number[][]"], + returnType: "number[][]", + testCase: "[[1,2],[3],[3],[]]", + }, + 798: { + funName: "bestRotation", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[2,3,1,4,0]", + }, + 799: { + funName: "champagneTower", + paramTypes: ["number", "number", "number"], + returnType: "number", + testCase: "1\\n1\\n1", + }, + 801: { + funName: "minSwap", + paramTypes: ["number[]", "number[]"], + returnType: "number", + testCase: "[1,3,5,4]\\n[1,2,3,7]", + }, + 802: { + funName: "eventualSafeNodes", + paramTypes: ["number[][]"], + returnType: "number[]", + testCase: "[[1,2],[2,3],[5],[0],[5],[],[]]", + }, + 803: { + funName: "hitBricks", + paramTypes: ["number[][]", "number[][]"], + returnType: "number[]", + testCase: "[[1,0,0,0],[1,1,1,0]]\\n[[1,0]]", + }, + 804: { + funName: "uniqueMorseRepresentations", + paramTypes: ["string[]"], + returnType: "number", + testCase: '["gin", "zen", "gig", "msg"]', + }, + 805: { + funName: "splitArraySameAverage", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[1,2,3,4,5,6,7,8]", + }, + 806: { + funName: "numberOfLines", + paramTypes: ["number[]", "string"], + returnType: "number[]", + testCase: + '[10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]\\n"abcdefghijklmnopqrstuvwxyz"', + }, + 807: { + funName: "maxIncreaseKeepingSkyline", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[3,0,8,4],[2,4,5,7],[9,2,6,3],[0,3,1,0]]", + }, + 808: { + funName: "soupServings", + paramTypes: ["number"], + returnType: "number", + testCase: "50", + }, + 809: { + funName: "expressiveWords", + paramTypes: ["string", "string[]"], + returnType: "number", + testCase: '"heeellooo"\\n["hello", "hi", "helo"]', + }, + 810: { + funName: "xorGame", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[1,1,2]", + }, + 811: { + funName: "subdomainVisits", + paramTypes: ["string[]"], + returnType: "string[]", + testCase: '["9001 discuss.leetcode.com"]', + }, + 812: { + funName: "largestTriangleArea", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[0,0],[0,1],[1,0],[0,2],[2,0]]", + }, + 813: { + funName: "largestSumOfAverages", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[9,1,2,3,9]\\n3", + }, + 814: { + funName: "pruneTree", + paramTypes: ["TreeNode"], + returnType: "TreeNode", + testCase: "[1,null,0,0,1]", + }, + 815: { + funName: "numBusesToDestination", + paramTypes: ["number[][]", "number", "number"], + returnType: "number", + testCase: "[[1,2,7],[3,6,7]]\\n1\\n6", + }, + 816: { + funName: "ambiguousCoordinates", + paramTypes: ["string"], + returnType: "string[]", + testCase: '"(123)"', + }, + 817: { + funName: "numComponents", + paramTypes: ["ListNode", "number[]"], + returnType: "number", + testCase: "[0,1,2,3]\\n[0,1,3]", + }, + 818: { + funName: "racecar", + paramTypes: ["number"], + returnType: "number", + testCase: "3", + }, + 819: { + funName: "mostCommonWord", + paramTypes: ["string", "string[]"], + returnType: "string", + testCase: '"Bob hit a ball, the hit BALL flew far after it was hit."\\n["hit"]', + }, + 820: { + funName: "minimumLengthEncoding", + paramTypes: ["string[]"], + returnType: "number", + testCase: '["time", "me", "bell"]', + }, + 821: { + funName: "shortestToChar", + paramTypes: ["string", "character"], + returnType: "number[]", + testCase: '"loveleetcode"\\n"e"', + }, + 822: { + funName: "flipgame", + paramTypes: ["number[]", "number[]"], + returnType: "number", + testCase: "[1,2,4,4,7]\\n[1,3,4,1,3]", + }, + 823: { + funName: "numFactoredBinaryTrees", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[2,4]", + }, + 824: { + funName: "toGoatLatin", + paramTypes: ["string"], + returnType: "string", + testCase: '"I speak Goat Latin"', + }, + 825: { + funName: "numFriendRequests", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[16,16]", + }, + 826: { + funName: "maxProfitAssignment", + paramTypes: ["number[]", "number[]", "number[]"], + returnType: "number", + testCase: "[2,4,6,8,10]\\n[10,20,30,40,50]\\n[4,5,6,7]", + }, + 827: { + funName: "largestIsland", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[1,0],[0,1]]", + }, + 828: { + funName: "uniqueLetterString", + paramTypes: ["string"], + returnType: "number", + testCase: '"ABC"', + }, + 829: { + funName: "consecutiveNumbersSum", + paramTypes: ["number"], + returnType: "number", + testCase: "5", + }, + 830: { + funName: "largeGroupPositions", + paramTypes: ["string"], + returnType: "number[][]", + testCase: '"abbxxxxzzy"', + }, + 831: { + funName: "maskPII", + paramTypes: ["string"], + returnType: "string", + testCase: '"LeetCode@LeetCode.com"', + }, + 832: { + funName: "flipAndInvertImage", + paramTypes: ["number[][]"], + returnType: "number[][]", + testCase: "[[1,1,0],[1,0,1],[0,0,0]]", + }, + 833: { + funName: "findReplaceString", + paramTypes: ["string", "number[]", "string[]", "string[]"], + returnType: "string", + testCase: '"abcd"\\n[0, 2]\\n["a", "cd"]\\n["eee", "ffff"]', + }, + 834: { + funName: "sumOfDistancesInTree", + paramTypes: ["number", "number[][]"], + returnType: "number[]", + testCase: "6\\n[[0,1],[0,2],[2,3],[2,4],[2,5]]", + }, + 835: { + funName: "largestOverlap", + paramTypes: ["number[][]", "number[][]"], + returnType: "number", + testCase: "[[1,1,0],[0,1,0],[0,1,0]]\\n[[0,0,0],[0,1,1],[0,0,1]]", + }, + 836: { + funName: "isRectangleOverlap", + paramTypes: ["number[]", "number[]"], + returnType: "boolean", + testCase: "[0,0,2,2]\\n[1,1,3,3]", + }, + 837: { + funName: "new21Game", + paramTypes: ["number", "number", "number"], + returnType: "number", + testCase: "10\\n1\\n10", + }, + 838: { + funName: "pushDominoes", + paramTypes: ["string"], + returnType: "string", + testCase: '".L.R...LR..L.."', + }, + 839: { + funName: "numSimilarGroups", + paramTypes: ["string[]"], + returnType: "number", + testCase: '["tars","rats","arts","star"]', + }, + 840: { + funName: "numMagicSquaresInside", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[4,3,8,4],[9,5,1,9],[2,7,6,2]]", + }, + 841: { + funName: "canVisitAllRooms", + paramTypes: ["number[][]"], + returnType: "boolean", + testCase: "[[1],[2],[3],[]]", + }, + 842: { + funName: "splitIntoFibonacci", + paramTypes: ["string"], + returnType: "number[]", + testCase: '"123456579"', + }, + 843: { + funName: "findSecretWord", + paramTypes: ["string[]", "Master"], + returnType: "void", + testCase: '"acckzz"\\n["acckzz","ccbazz","eiowzz","abcczz"]\\n10', + }, + 844: { + funName: "backspaceCompare", + paramTypes: ["string", "string"], + returnType: "boolean", + testCase: '"ab#c"\\n"ad#c"', + }, + 845: { + funName: "longestMountain", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[2,1,4,7,3,2,5]", + }, + 846: { + funName: "isNStraightHand", + paramTypes: ["number[]", "number"], + returnType: "boolean", + testCase: "[1,2,3,6,2,3,4,7,8]\\n3", + }, + 847: { + funName: "shortestPathLength", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[1,2,3],[0],[0],[0]]", + }, + 848: { + funName: "shiftingLetters", + paramTypes: ["string", "number[]"], + returnType: "string", + testCase: '"abc"\\n[3,5,9]', + }, + 849: { + funName: "maxDistToClosest", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,0,0,0,1,0,1]", + }, + 850: { + funName: "rectangleArea", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[0,0,2,2],[1,0,2,3],[1,0,3,1]]", + }, + 851: { + funName: "loudAndRich", + paramTypes: ["number[][]", "number[]"], + returnType: "number[]", + testCase: "[[1,0],[2,1],[3,1],[3,7],[4,3],[5,3],[6,3]]\\n[3,2,5,4,6,1,7,0]", + }, + 852: { + funName: "peakIndexInMountainArray", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[0,1,0]", + }, + 853: { + funName: "carFleet", + paramTypes: ["number", "number[]", "number[]"], + returnType: "number", + testCase: "12\\n[10,8,0,5,3]\\n[2,4,1,1,3]", + }, + 854: { + funName: "kSimilarity", + paramTypes: ["string", "string"], + returnType: "number", + testCase: '"ab"\\n"ba"', + }, + 855: { + funName: "ExamRoom", + paramTypes: ["number"], + returnType: "void", + testCase: '["ExamRoom","seat","seat","seat","seat","leave","seat"]\\n[[10],[],[],[],[],[4],[]]', + }, + 856: { + funName: "scoreOfParentheses", + paramTypes: ["string"], + returnType: "number", + testCase: '"()"', + }, + 857: { + funName: "mincostToHireWorkers", + paramTypes: ["number[]", "number[]", "number"], + returnType: "number", + testCase: "[10,20,5]\\n[70,50,30]\\n2", + }, + 858: { + funName: "mirrorReflection", + paramTypes: ["number", "number"], + returnType: "number", + testCase: "2\\n1", + }, + 859: { + funName: "buddyStrings", + paramTypes: ["string", "string"], + returnType: "boolean", + testCase: '"ab"\\n"ba"', + }, + 860: { + funName: "lemonadeChange", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[5,5,5,10,20]", + }, + 861: { + funName: "matrixScore", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[0,0,1,1],[1,0,1,0],[1,1,0,0]]", + }, + 862: { + funName: "shortestSubarray", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1]\\n1", + }, + 863: { + funName: "distanceK", + paramTypes: ["TreeNode", "TreeNode", "number"], + returnType: "number[]", + testCase: "[3,5,1,6,2,0,8,null,null,7,4]\\n5\\n2", + }, + 864: { + funName: "shortestPathAllKeys", + paramTypes: ["string[]"], + returnType: "number", + testCase: '["@.a.#","###.#","b.A.B"]', + }, + 865: { + funName: "subtreeWithAllDeepest", + paramTypes: ["TreeNode"], + returnType: "TreeNode", + testCase: "[3,5,1,6,2,0,8,null,null,7,4]", + }, + 866: { + funName: "primePalindrome", + paramTypes: ["number"], + returnType: "number", + testCase: "6", + }, + 867: { + funName: "transpose", + paramTypes: ["number[][]"], + returnType: "number[][]", + testCase: "[[1,2,3],[4,5,6],[7,8,9]]", + }, + 868: { + funName: "binaryGap", + paramTypes: ["number"], + returnType: "number", + testCase: "22", + }, + 869: { + funName: "reorderedPowerOf2", + paramTypes: ["number"], + returnType: "boolean", + testCase: "1", + }, + 870: { + funName: "advantageCount", + paramTypes: ["number[]", "number[]"], + returnType: "number[]", + testCase: "[2,7,11,15]\\n[1,10,4,11]", + }, + 871: { + funName: "minRefuelStops", + paramTypes: ["number", "number", "number[][]"], + returnType: "number", + testCase: "1\\n1\\n[]", + }, + 872: { + funName: "leafSimilar", + paramTypes: ["TreeNode", "TreeNode"], + returnType: "boolean", + testCase: "[3,5,1,6,2,9,8,null,null,7,4]\\n[3,5,1,6,7,4,2,null,null,null,null,null,null,9,8]", + }, + 873: { + funName: "lenLongestFibSubseq", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,2,3,4,5,6,7,8]", + }, + 874: { + funName: "robotSim", + paramTypes: ["number[]", "number[][]"], + returnType: "number", + testCase: "[4,-1,3]\\n[]", + }, + 875: { + funName: "minEatingSpeed", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[3,6,7,11]\\n8", + }, + 876: { + funName: "middleNode", + paramTypes: ["ListNode"], + returnType: "ListNode", + testCase: "[1,2,3,4,5]", + }, + 877: { + funName: "stoneGame", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[5,3,4,5]", + }, + 878: { + funName: "nthMagicalNumber", + paramTypes: ["number", "number", "number"], + returnType: "number", + testCase: "1\\n2\\n3", + }, + 879: { + funName: "profitableSchemes", + paramTypes: ["number", "number", "number[]", "number[]"], + returnType: "number", + testCase: "5\\n3\\n[2,2]\\n[2,3]", + }, + 880: { + funName: "decodeAtIndex", + paramTypes: ["string", "number"], + returnType: "string", + testCase: '"leet2code3"\\n10', + }, + 881: { + funName: "numRescueBoats", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1,2]\\n3", + }, + 882: { + funName: "reachableNodes", + paramTypes: ["number[][]", "number", "number"], + returnType: "number", + testCase: "[[0,1,10],[0,2,1],[1,2,2]]\\n6\\n3", + }, + 883: { + funName: "projectionArea", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[2]]", + }, + 884: { + funName: "uncommonFromSentences", + paramTypes: ["string", "string"], + returnType: "string[]", + testCase: '"this apple is sweet"\\n"this apple is sour"', + }, + 885: { + funName: "spiralMatrixIII", + paramTypes: ["number", "number", "number", "number"], + returnType: "number[][]", + testCase: "1\\n4\\n0\\n0", + }, + 886: { + funName: "possibleBipartition", + paramTypes: ["number", "number[][]"], + returnType: "boolean", + testCase: "4\\n[[1,2],[1,3],[2,4]]", + }, + 887: { + funName: "superEggDrop", + paramTypes: ["number", "number"], + returnType: "number", + testCase: "1\\n2", + }, + 888: { + funName: "fairCandySwap", + paramTypes: ["number[]", "number[]"], + returnType: "number[]", + testCase: "[1,1]\\n[2,2]", + }, + 889: { + funName: "constructFromPrePost", + paramTypes: ["number[]", "number[]"], + returnType: "TreeNode", + testCase: "[1,2,4,5,3,6,7]\\n[4,5,2,6,7,3,1]", + }, + 890: { + funName: "findAndReplacePattern", + paramTypes: ["string[]", "string"], + returnType: "string[]", + testCase: '["abc","deq","mee","aqq","dkd","ccc"]\\n"abb"', + }, + 891: { + funName: "sumSubseqWidths", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[2,1,3]", + }, + 892: { + funName: "surfaceArea", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[2]]", + }, + 893: { + funName: "numSpecialEquivGroups", + paramTypes: ["string[]"], + returnType: "number", + testCase: '["abcd","cdab","cbad","xyzz","zzxy","zzyx"]', + }, + 894: { + funName: "allPossibleFBT", + paramTypes: ["number"], + returnType: "TreeNode[]", + testCase: "7", + }, + 895: { + funName: "FreqStack", + paramTypes: [], + returnType: "void", + testCase: + '["FreqStack","push","push","push","push","push","push","pop","pop","pop","pop"]\\n[[],[5],[7],[5],[7],[4],[5],[],[],[],[]]', + }, + 896: { + funName: "isMonotonic", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[1,2,2,3]", + }, + 897: { + funName: "increasingBST", + paramTypes: ["TreeNode"], + returnType: "TreeNode", + testCase: "[5,3,6,2,4,null,8,1,null,null,null,7,9]", + }, + 898: { + funName: "subarrayBitwiseORs", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[0]", + }, + 899: { + funName: "orderlyQueue", + paramTypes: ["string", "number"], + returnType: "string", + testCase: '"cba"\\n1', + }, + 900: { + funName: "RLEIterator", + paramTypes: ["number[]"], + returnType: "void", + testCase: '["RLEIterator","next","next","next","next"]\\n[[[3,8,0,9,2,5]],[2],[1],[1],[2]]', + }, + 901: { + funName: "StockSpanner", + paramTypes: [], + returnType: "void", + testCase: + '["StockSpanner","next","next","next","next","next","next","next"]\\n[[],[100],[80],[60],[70],[60],[75],[85]]', + }, + 902: { + funName: "atMostNGivenDigitSet", + paramTypes: ["string[]", "number"], + returnType: "number", + testCase: '["1","3","5","7"]\\n100', + }, + 903: { + funName: "numPermsDISequence", + paramTypes: ["string"], + returnType: "number", + testCase: '"DID"', + }, + 904: { + funName: "totalFruit", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,2,1]", + }, + 905: { + funName: "sortArrayByParity", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[3,1,2,4]", + }, + 906: { + funName: "superpalindromesInRange", + paramTypes: ["string", "string"], + returnType: "number", + testCase: '"4"\\n"1000"', + }, + 907: { + funName: "sumSubarrayMins", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[3,1,2,4]", + }, + 908: { + funName: "smallestRangeI", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1]\\n0", + }, + 909: { + funName: "snakesAndLadders", + paramTypes: ["number[][]"], + returnType: "number", + testCase: + "[[-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1],[-1,35,-1,-1,13,-1],[-1,-1,-1,-1,-1,-1],[-1,15,-1,-1,-1,-1]]", + }, + 910: { + funName: "smallestRangeII", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1]\\n0", + }, + 911: { + funName: "TopVotedCandidate", + paramTypes: ["number[]", "number[]"], + returnType: "void", + testCase: + '["TopVotedCandidate","q","q","q","q","q","q"]\\n[[[0,1,1,0,0,1,0],[0,5,10,15,20,25,30]],[3],[12],[25],[15],[24],[8]]', + }, + 912: { + funName: "sortArray", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[5,2,3,1]", + }, + 913: { + funName: "catMouseGame", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[2,5],[3],[0,4,5],[1,4,5],[2,3],[0,2,3]]", + }, + 914: { + funName: "hasGroupsSizeX", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[1,2,3,4,4,3,2,1]", + }, + 915: { + funName: "partitionDisjoint", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[5,0,3,8,6]", + }, + 916: { + funName: "wordSubsets", + paramTypes: ["string[]", "string[]"], + returnType: "string[]", + testCase: '["amazon","apple","facebook","google","leetcode"]\\n["e","o"]', + }, + 917: { + funName: "reverseOnlyLetters", + paramTypes: ["string"], + returnType: "string", + testCase: '"ab-cd"', + }, + 918: { + funName: "maxSubarraySumCircular", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,-2,3,-2]", + }, + 919: { + funName: "CBTInserter", + paramTypes: ["TreeNode"], + returnType: "void", + testCase: '["CBTInserter","insert","get_root"]\\n[[[1]],[2],[]]', + }, + 920: { + funName: "numMusicPlaylists", + paramTypes: ["number", "number", "number"], + returnType: "number", + testCase: "3\\n3\\n1", + }, + 921: { + funName: "minAddToMakeValid", + paramTypes: ["string"], + returnType: "number", + testCase: '"())"', + }, + 922: { + funName: "sortArrayByParityII", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[4,2,5,7]", + }, + 923: { + funName: "threeSumMulti", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1,1,2,2,3,3,4,4,5,5]\\n8", + }, + 924: { + funName: "minMalwareSpread", + paramTypes: ["number[][]", "number[]"], + returnType: "number", + testCase: "[[1,1,0],[1,1,0],[0,0,1]]\\n[0,1]", + }, + 925: { + funName: "isLongPressedName", + paramTypes: ["string", "string"], + returnType: "boolean", + testCase: '"alex"\\n"aaleex"', + }, + 926: { + funName: "minFlipsMonoIncr", + paramTypes: ["string"], + returnType: "number", + testCase: '"00110"', + }, + 927: { + funName: "threeEqualParts", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[1,0,1,0,1]", + }, + 928: { + funName: "minMalwareSpread", + paramTypes: ["number[][]", "number[]"], + returnType: "number", + testCase: "[[1,1,0],[1,1,0],[0,0,1]]\\n[0,1]", + }, + 929: { + funName: "numUniqueEmails", + paramTypes: ["string[]"], + returnType: "number", + testCase: + '["test.email+alex@leetcode.com","test.e.mail+bob.cathy@leetcode.com","testemail+david@lee.tcode.com"]', + }, + 930: { + funName: "numSubarraysWithSum", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1,0,1,0,1]\\n2", + }, + 931: { + funName: "minFallingPathSum", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[1,2,3],[4,5,6],[7,8,9]]", + }, + 932: { + funName: "beautifulArray", + paramTypes: ["number"], + returnType: "number[]", + testCase: "4", + }, + 933: { + funName: "RecentCounter", + paramTypes: [], + returnType: "void", + testCase: '["RecentCounter","ping","ping","ping","ping"]\\n[[],[1],[100],[3001],[3002]]', + }, + 934: { + funName: "shortestBridge", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[0,1],[1,0]]", + }, + 935: { + funName: "knightDialer", + paramTypes: ["number"], + returnType: "number", + testCase: "1", + }, + 936: { + funName: "movesToStamp", + paramTypes: ["string", "string"], + returnType: "number[]", + testCase: '"abc"\\n"ababc"', + }, + 937: { + funName: "reorderLogFiles", + paramTypes: ["string[]"], + returnType: "string[]", + testCase: '["dig1 8 1 5 1","let1 art can","dig2 3 6","let2 own kit dig","let3 art zero"]', + }, + 938: { + funName: "rangeSumBST", + paramTypes: ["TreeNode", "number", "number"], + returnType: "number", + testCase: "[10,5,15,3,7,null,18]\\n7\\n15", + }, + 939: { + funName: "minAreaRect", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[1,1],[1,3],[3,1],[3,3],[2,2]]", + }, + 940: { + funName: "distinctSubseqII", + paramTypes: ["string"], + returnType: "number", + testCase: '"abc"', + }, + 941: { + funName: "validMountainArray", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[2,1]", + }, + 942: { + funName: "diStringMatch", + paramTypes: ["string"], + returnType: "number[]", + testCase: '"IDID"', + }, + 943: { + funName: "shortestSuperstring", + paramTypes: ["string[]"], + returnType: "string", + testCase: '["alex","loves","leetcode"]', + }, + 944: { + funName: "minDeletionSize", + paramTypes: ["string[]"], + returnType: "number", + testCase: '["cba","daf","ghi"]', + }, + 945: { + funName: "minIncrementForUnique", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,2,2]", + }, + 946: { + funName: "validateStackSequences", + paramTypes: ["number[]", "number[]"], + returnType: "boolean", + testCase: "[1,2,3,4,5]\\n[4,5,3,2,1]", + }, + 947: { + funName: "removeStones", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[0,0],[0,1],[1,0],[1,2],[2,1],[2,2]]", + }, + 948: { + funName: "bagOfTokensScore", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[100]\\n50", + }, + 949: { + funName: "largestTimeFromDigits", + paramTypes: ["number[]"], + returnType: "string", + testCase: "[1,2,3,4]", + }, + 950: { + funName: "deckRevealedIncreasing", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[17,13,11,2,3,5,7]", + }, + 951: { + funName: "flipEquiv", + paramTypes: ["TreeNode", "TreeNode"], + returnType: "boolean", + testCase: "[1,2,3,4,5,6,null,null,null,7,8]\\n[1,3,2,null,6,4,5,null,null,null,null,8,7]", + }, + 952: { + funName: "largestComponentSize", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[4,6,15,35]", + }, + 953: { + funName: "isAlienSorted", + paramTypes: ["string[]", "string"], + returnType: "boolean", + testCase: '["hello","leetcode"]\\n"hlabcdefgijkmnopqrstuvwxyz"', + }, + 954: { + funName: "canReorderDoubled", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[3,1,3,6]", + }, + 955: { + funName: "minDeletionSize", + paramTypes: ["string[]"], + returnType: "number", + testCase: '["ca","bb","ac"]', + }, + 956: { + funName: "tallestBillboard", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,2,3,6]", + }, + 957: { + funName: "prisonAfterNDays", + paramTypes: ["number[]", "number"], + returnType: "number[]", + testCase: "[0,1,0,1,1,0,0,1]\\n7", + }, + 958: { + funName: "isCompleteTree", + paramTypes: ["TreeNode"], + returnType: "boolean", + testCase: "[1,2,3,4,5,6]", + }, + 959: { + funName: "regionsBySlashes", + paramTypes: ["string[]"], + returnType: "number", + testCase: '[" /","/ "]', + }, + 960: { + funName: "minDeletionSize", + paramTypes: ["string[]"], + returnType: "number", + testCase: '["babca","bbazb"]', + }, + 961: { + funName: "repeatedNTimes", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,2,3,3]", + }, + 962: { + funName: "maxWidthRamp", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[6,0,8,2,1,5]", + }, + 963: { + funName: "minAreaFreeRect", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[1,2],[2,1],[1,0],[0,1]]", + }, + 964: { + funName: "leastOpsExpressTarget", + paramTypes: ["number", "number"], + returnType: "number", + testCase: "3\\n19", + }, + 965: { + funName: "isUnivalTree", + paramTypes: ["TreeNode"], + returnType: "boolean", + testCase: "[1,1,1,1,1,null,1]", + }, + 966: { + funName: "spellchecker", + paramTypes: ["string[]", "string[]"], + returnType: "string[]", + testCase: + '["KiTe","kite","hare","Hare"]\\n["kite","Kite","KiTe","Hare","HARE","Hear","hear","keti","keet","keto"]', + }, + 967: { + funName: "numsSameConsecDiff", + paramTypes: ["number", "number"], + returnType: "number[]", + testCase: "3\\n7", + }, + 968: { + funName: "minCameraCover", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[0,0,null,0,0]", + }, + 969: { + funName: "pancakeSort", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[3,2,4,1]", + }, + 970: { + funName: "powerfulIntegers", + paramTypes: ["number", "number", "number"], + returnType: "number[]", + testCase: "2\\n3\\n10", + }, + 971: { + funName: "flipMatchVoyage", + paramTypes: ["TreeNode", "number[]"], + returnType: "number[]", + testCase: "[1,2]\\n[2,1]", + }, + 972: { + funName: "isRationalEqual", + paramTypes: ["string", "string"], + returnType: "boolean", + testCase: '"0.(52)"\\n"0.5(25)"', + }, + 973: { + funName: "kClosest", + paramTypes: ["number[][]", "number"], + returnType: "number[][]", + testCase: "[[1,3],[-2,2]]\\n1", + }, + 974: { + funName: "subarraysDivByK", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[4,5,0,-2,-3,1]\\n5", + }, + 975: { + funName: "oddEvenJumps", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[10,13,12,14,15]", + }, + 976: { + funName: "largestPerimeter", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[2,1,2]", + }, + 977: { + funName: "sortedSquares", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[-4,-1,0,3,10]", + }, + 978: { + funName: "maxTurbulenceSize", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[9,4,2,10,7,8,8,1,9]", + }, + 979: { + funName: "distributeCoins", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[3,0,0]", + }, + 980: { + funName: "uniquePathsIII", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[1,0,0,0],[0,0,0,0],[0,0,2,-1]]", + }, + 981: { + funName: "TimeMap", + paramTypes: [], + returnType: "void", + testCase: + '["TimeMap","set","get","get","set","get","get"]\\n[[],["foo","bar",1],["foo",1],["foo",3],["foo","bar2",4],["foo",4],["foo",5]]', + }, + 982: { + funName: "countTriplets", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[2,1,3]", + }, + 983: { + funName: "mincostTickets", + paramTypes: ["number[]", "number[]"], + returnType: "number", + testCase: "[1,4,6,7,8,20]\\n[2,7,15]", + }, + 984: { + funName: "strWithout3a3b", + paramTypes: ["number", "number"], + returnType: "string", + testCase: "1\\n2", + }, + 985: { + funName: "sumEvenAfterQueries", + paramTypes: ["number[]", "number[][]"], + returnType: "number[]", + testCase: "[1,2,3,4]\\n[[1,0],[-3,1],[-4,0],[2,3]]", + }, + 986: { + funName: "intervalIntersection", + paramTypes: ["number[][]", "number[][]"], + returnType: "number[][]", + testCase: "[[0,2],[5,10],[13,23],[24,25]]\\n[[1,5],[8,12],[15,24],[25,26]]", + }, + 987: { + funName: "verticalTraversal", + paramTypes: ["TreeNode"], + returnType: "number[][]", + testCase: "[3,9,20,null,null,15,7]", + }, + 988: { + funName: "smallestFromLeaf", + paramTypes: ["TreeNode"], + returnType: "string", + testCase: "[0,1,2,3,4,3,4]", + }, + 989: { + funName: "addToArrayForm", + paramTypes: ["number[]", "number"], + returnType: "number[]", + testCase: "[1,2,0,0]\\n34", + }, + 990: { + funName: "equationsPossible", + paramTypes: ["string[]"], + returnType: "boolean", + testCase: '["a==b","b!=a"]', + }, + 991: { + funName: "brokenCalc", + paramTypes: ["number", "number"], + returnType: "number", + testCase: "2\\n3", + }, + 992: { + funName: "subarraysWithKDistinct", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1,2,1,2,3]\\n2", + }, + 993: { + funName: "isCousins", + paramTypes: ["TreeNode", "number", "number"], + returnType: "boolean", + testCase: "[1,2,3,4]\\n4\\n3", + }, + 994: { + funName: "orangesRotting", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[2,1,1],[1,1,0],[0,1,1]]", + }, + 995: { + funName: "minKBitFlips", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[0,1,0]\\n1", + }, + 996: { + funName: "numSquarefulPerms", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,17,8]", + }, + 997: { + funName: "findJudge", + paramTypes: ["number", "number[][]"], + returnType: "number", + testCase: "2\\n[[1,2]]", + }, + 998: { + funName: "insertIntoMaxTree", + paramTypes: ["TreeNode", "number"], + returnType: "TreeNode", + testCase: "[4,1,3,null,null,2]\\n5", + }, + 999: { + funName: "numRookCaptures", + paramTypes: ["character[][]"], + returnType: "number", + testCase: + '[[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".","R",".",".",".","p"],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."]]', + }, + 1000: { + funName: "mergeStones", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[3,2,4,1]\\n2", + }, + 1001: { + funName: "gridIllumination", + paramTypes: ["number", "number[][]", "number[][]"], + returnType: "number[]", + testCase: "5\\n[[0,0],[4,4]]\\n[[1,1],[1,0]]", + }, + 1002: { + funName: "commonChars", + paramTypes: ["string[]"], + returnType: "string[]", + testCase: '["bella","label","roller"]', + }, + 1003: { + funName: "isValid", + paramTypes: ["string"], + returnType: "boolean", + testCase: '"aabcbc"', + }, + 1004: { + funName: "longestOnes", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1,1,1,0,0,0,1,1,1,1,0]\\n2", + }, + 1005: { + funName: "largestSumAfterKNegations", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[4,2,3]\\n1", + }, + 1006: { + funName: "clumsy", + paramTypes: ["number"], + returnType: "number", + testCase: "4", + }, + 1007: { + funName: "minDominoRotations", + paramTypes: ["number[]", "number[]"], + returnType: "number", + testCase: "[2,1,2,4,2,2]\\n[5,2,6,2,3,2]", + }, + 1008: { + funName: "bstFromPreorder", + paramTypes: ["number[]"], + returnType: "TreeNode", + testCase: "[8,5,1,7,10,12]", + }, + 1009: { + funName: "bitwiseComplement", + paramTypes: ["number"], + returnType: "number", + testCase: "5", + }, + 1010: { + funName: "numPairsDivisibleBy60", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[30,20,150,100,40]", + }, + 1011: { + funName: "shipWithinDays", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1,2,3,4,5,6,7,8,9,10]\\n5", + }, + 1012: { + funName: "numDupDigitsAtMostN", + paramTypes: ["number"], + returnType: "number", + testCase: "20", + }, + 1013: { + funName: "canThreePartsEqualSum", + paramTypes: ["number[]"], + returnType: "boolean", + testCase: "[0,2,1,-6,6,-7,9,1,2,0,1]", + }, + 1014: { + funName: "maxScoreSightseeingPair", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[8,1,5,2,6]", + }, + 1015: { + funName: "smallestRepunitDivByK", + paramTypes: ["number"], + returnType: "number", + testCase: "1", + }, + 1016: { + funName: "queryString", + paramTypes: ["string", "number"], + returnType: "boolean", + testCase: '"0110"\\n3', + }, + 1017: { + funName: "baseNeg2", + paramTypes: ["number"], + returnType: "string", + testCase: "2", + }, + 1018: { + funName: "prefixesDivBy5", + paramTypes: ["number[]"], + returnType: "boolean[]", + testCase: "[0,1,1]", + }, + 1019: { + funName: "nextLargerNodes", + paramTypes: ["ListNode"], + returnType: "number[]", + testCase: "[2,1,5]", + }, + 1020: { + funName: "numEnclaves", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[0,0,0,0],[1,0,1,0],[0,1,1,0],[0,0,0,0]]", + }, + 1021: { + funName: "removeOuterParentheses", + paramTypes: ["string"], + returnType: "string", + testCase: '"(()())(())"', + }, + 1022: { + funName: "sumRootToLeaf", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[1,0,1,0,1,0,1]", + }, + 1023: { + funName: "camelMatch", + paramTypes: ["string[]", "string"], + returnType: "boolean[]", + testCase: '["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"]\\n"FB"', + }, + 1024: { + funName: "videoStitching", + paramTypes: ["number[][]", "number"], + returnType: "number", + testCase: "[[0,2],[4,6],[8,10],[1,9],[1,5],[5,9]]\\n10", + }, + 1025: { + funName: "divisorGame", + paramTypes: ["number"], + returnType: "boolean", + testCase: "2", + }, + 1026: { + funName: "maxAncestorDiff", + paramTypes: ["TreeNode"], + returnType: "number", + testCase: "[8,3,10,1,6,null,14,null,null,4,7,13]", + }, + 1027: { + funName: "longestArithSeqLength", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[3,6,9,12]", + }, + 1028: { + funName: "recoverFromPreorder", + paramTypes: ["string"], + returnType: "TreeNode", + testCase: '"1-2--3--4-5--6--7"', + }, + 1029: { + funName: "twoCitySchedCost", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[10,20],[30,200],[400,50],[30,20]]", + }, + 1030: { + funName: "allCellsDistOrder", + paramTypes: ["number", "number", "number", "number"], + returnType: "number[][]", + testCase: "1\\n2\\n0\\n0", + }, + 1031: { + funName: "maxSumTwoNoOverlap", + paramTypes: ["number[]", "number", "number"], + returnType: "number", + testCase: "[0,6,5,2,2,5,1,9,4]\\n1\\n2", + }, + 1032: { + funName: "StreamChecker", + paramTypes: ["string[]"], + returnType: "void", + testCase: + '["StreamChecker","query","query","query","query","query","query","query","query","query","query","query","query"]\\n[[["cd","f","kl"]],["a"],["b"],["c"],["d"],["e"],["f"],["g"],["h"],["i"],["j"],["k"],["l"]]', + }, + 1033: { + funName: "numMovesStones", + paramTypes: ["number", "number", "number"], + returnType: "number[]", + testCase: "1\\n2\\n5", + }, + 1034: { + funName: "colorBorder", + paramTypes: ["number[][]", "number", "number", "number"], + returnType: "number[][]", + testCase: "[[1,1],[1,2]]\\n0\\n0\\n3", + }, + 1035: { + funName: "maxUncrossedLines", + paramTypes: ["number[]", "number[]"], + returnType: "number", + testCase: "[1,4,2]\\n[1,2,4]", + }, + 1036: { + funName: "isEscapePossible", + paramTypes: ["number[][]", "number[]", "number[]"], + returnType: "boolean", + testCase: "[[0,1],[1,0]]\\n[0,0]\\n[0,2]", + }, + 1037: { + funName: "isBoomerang", + paramTypes: ["number[][]"], + returnType: "boolean", + testCase: "[[1,1],[2,3],[3,2]]", + }, + 1038: { + funName: "bstToGst", + paramTypes: ["TreeNode"], + returnType: "TreeNode", + testCase: "[4,1,6,0,2,5,7,null,null,null,3,null,null,null,8]", + }, + 1039: { + funName: "minScoreTriangulation", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,2,3]", + }, + 1040: { + funName: "numMovesStonesII", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[7,4,9]", + }, + 1041: { + funName: "isRobotBounded", + paramTypes: ["string"], + returnType: "boolean", + testCase: '"GGLLGG"', + }, + 1042: { + funName: "gardenNoAdj", + paramTypes: ["number", "number[][]"], + returnType: "number[]", + testCase: "3\\n[[1,2],[2,3],[3,1]]", + }, + 1043: { + funName: "maxSumAfterPartitioning", + paramTypes: ["number[]", "number"], + returnType: "number", + testCase: "[1,15,7,9,2,5,10]\\n3", + }, + 1044: { + funName: "longestDupSubstring", + paramTypes: ["string"], + returnType: "string", + testCase: '"banana"', + }, + 1046: { + funName: "lastStoneWeight", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[2,7,4,1,8,1]", + }, + 1047: { + funName: "removeDuplicates", + paramTypes: ["string"], + returnType: "string", + testCase: '"abbaca"', + }, + 1048: { + funName: "longestStrChain", + paramTypes: ["string[]"], + returnType: "number", + testCase: '["a","b","ba","bca","bda","bdca"]', + }, + 1049: { + funName: "lastStoneWeightII", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[2,7,4,1,8,1]", + }, + 1051: { + funName: "heightChecker", + paramTypes: ["number[]"], + returnType: "number", + testCase: "[1,1,4,2,1,3]", + }, + 1052: { + funName: "maxSatisfied", + paramTypes: ["number[]", "number[]", "number"], + returnType: "number", + testCase: "[1,0,1,2,1,1,7,5]\\n[0,1,0,1,0,1,0,1]\\n3", + }, + 1053: { + funName: "prevPermOpt1", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[3,2,1]", + }, + 1054: { + funName: "rearrangeBarcodes", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: "[1,1,1,2,2,2]", + }, + 1071: { + funName: "gcdOfStrings", + paramTypes: ["string", "string"], + returnType: "string", + testCase: '"ABCABC"\\n"ABC"', + }, + 1072: { + funName: "maxEqualRowsAfterFlips", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[0,1],[1,1]]", + }, + 1073: { + funName: "addNegabinary", + paramTypes: ["number[]", "number[]"], + returnType: "number[]", + testCase: "[1,1,1,1,1]\\n[1,0,1]", + }, + 1074: { + funName: "numSubmatrixSumTarget", + paramTypes: ["number[][]", "number"], + returnType: "number", + testCase: "[[0,1,0],[1,1,1],[0,1,0]]\\n0", + }, + 1078: { + funName: "findOcurrences", + paramTypes: ["string", "string", "string"], + returnType: "string[]", + testCase: '"alice is a good girl she is a good student"\\n"a"\\n"good"', + }, + 1079: { + funName: "numTilePossibilities", + paramTypes: ["string"], + returnType: "number", + testCase: '"AAB"', + }, + 1080: { + funName: "sufficientSubset", + paramTypes: ["TreeNode", "number"], + returnType: "TreeNode", + testCase: "[1,2,3,4,-99,-99,7,8,9,-99,-99,12,13,-99,14]\\n1", + }, + 1081: { + funName: "smallestSubsequence", + paramTypes: ["string"], + returnType: "string", + testCase: '"cdadabcc"', + }, + 1089: { + funName: "duplicateZeros", + paramTypes: ["number[]"], + returnType: "void", + testCase: "[1,0,2,3,0,4,5,0]", + }, + 1090: { + funName: "largestValsFromLabels", + paramTypes: ["number[]", "number[]", "number", "number"], + returnType: "number", + testCase: "[5,4,3,2,1]\\n[1,1,2,2,3]\\n3\\n1", + }, + 1091: { + funName: "shortestPathBinaryMatrix", + paramTypes: ["number[][]"], + returnType: "number", + testCase: "[[0,1],[1,0]]", + }, + 1092: { + funName: "shortestCommonSupersequence", + paramTypes: ["string", "string"], + returnType: "string", + testCase: '"abac"\\n"cab"', + }, + 1093: { + funName: "sampleStats", + paramTypes: ["number[]"], + returnType: "number[]", + testCase: + "[0,1,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]", + }, + 1094: { + funName: "carPooling", + paramTypes: ["number[][]", "number"], + returnType: "boolean", + testCase: "[[2,1,5],[3,3,7]]\\n4", + }, + 1095: { + funName: "findInMountainArray", + paramTypes: ["number", "MountainArray"], + returnType: "number", + testCase: "[1,2,3,4,5,3,1]\\n3", + }, + 1096: { + funName: "braceExpansionII", + paramTypes: ["string"], + returnType: "string[]", + testCase: '"{a,b}{c,{d,e}}"', + }, + 1103: { + funName: "distributeCandies", + paramTypes: ["number", "number"], + returnType: "number[]", + testCase: "7\\n4", + }, + 1104: { + funName: "pathInZigZagTree", + paramTypes: ["number"], + returnType: "number[]", + testCase: "14", + }, + 1105: { + funName: "minHeightShelves", + paramTypes: ["number[][]", "number"], + returnType: "number", + testCase: "[[1,1],[2,3],[2,3],[1,1],[1,1],[1,1],[1,2]]\\n4", + }, + 1106: { + funName: "parseBoolExpr", + paramTypes: ["string"], + returnType: "boolean", + testCase: '"!(f)"', + }, +}; diff --git a/src/extension.ts b/src/extension.ts index 9bb3ad41..1a6e25f9 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -14,11 +14,13 @@ import * as test from "./commands/test"; import { explorerNodeManager } from "./explorer/explorerNodeManager"; import { LeetCodeNode } from "./explorer/LeetCodeNode"; import { leetCodeTreeDataProvider } from "./explorer/LeetCodeTreeDataProvider"; +import { extensionState } from "./extensionState"; import { leetCodeChannel } from "./leetCodeChannel"; import { leetCodeExecutor } from "./leetCodeExecutor"; import { leetCodeManager } from "./leetCodeManager"; import { leetCodeStatusBarController } from "./statusbar/leetCodeStatusBarController"; import { DialogType, promptForOpenOutputChannel } from "./utils/uiUtils"; +import { checkCachePath } from "./utils/workspaceUtils"; import { leetCodePreviewProvider } from "./webview/leetCodePreviewProvider"; import { leetCodeSolutionProvider } from "./webview/leetCodeSolutionProvider"; import { leetCodeSubmissionProvider } from "./webview/leetCodeSubmissionProvider"; @@ -26,6 +28,10 @@ import { markdownEngine } from "./webview/markdownEngine"; export async function activate(context: vscode.ExtensionContext): Promise { try { + extensionState.context = context; + extensionState.cachePath = context.globalStoragePath; + checkCachePath(extensionState.cachePath); + if (!await leetCodeExecutor.meetRequirements()) { throw new Error("The environment doesn't meet requirements."); } diff --git a/src/extensionState.ts b/src/extensionState.ts new file mode 100644 index 00000000..668b9ecc --- /dev/null +++ b/src/extensionState.ts @@ -0,0 +1,11 @@ +import * as vscode from "vscode"; + +interface IExtensionState { + context: vscode.ExtensionContext; + cachePath: string; +} + +export const extensionState: IExtensionState = { + context: (null as any), + cachePath: "", +}; diff --git a/src/leetCodeExecutor.ts b/src/leetCodeExecutor.ts index 4c0aa312..6f5f0cce 100644 --- a/src/leetCodeExecutor.ts +++ b/src/leetCodeExecutor.ts @@ -8,6 +8,7 @@ import * as requireFromString from "require-from-string"; import { ConfigurationChangeEvent, Disposable, MessageItem, window, workspace, WorkspaceConfiguration } from "vscode"; import { Endpoint, IProblem, supportedPlugins } from "./shared"; import { executeCommand, executeCommandWithProgress } from "./utils/cpUtils"; +import { getUnstubedFile } from "./utils/problemUtils"; import { DialogOptions, openUrl } from "./utils/uiUtils"; import * as wsl from "./utils/wslUtils"; import { toWslPath, useWsl } from "./utils/wslUtils"; @@ -36,7 +37,7 @@ class LeetCodeExecutor implements Disposable { public async meetRequirements(): Promise { if (this.nodeExecutable !== "node") { - if (!await fse.pathExists(this.nodeExecutable)) { + if (!(await fse.pathExists(this.nodeExecutable))) { throw new Error(`The Node.js executable does not exist on path ${this.nodeExecutable}`); } // Wrap the executable with "" to avoid space issue in the path. @@ -58,10 +59,22 @@ class LeetCodeExecutor implements Disposable { return false; } for (const plugin of supportedPlugins) { - try { // Check plugin - await this.executeCommandEx(this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "plugin", "-e", plugin]); - } catch (error) { // Download plugin and activate - await this.executeCommandEx(this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "plugin", "-i", plugin]); + try { + // Check plugin + await this.executeCommandEx(this.nodeExecutable, [ + await this.getLeetCodeBinaryPath(), + "plugin", + "-e", + plugin, + ]); + } catch (error) { + // Download plugin and activate + await this.executeCommandEx(this.nodeExecutable, [ + await this.getLeetCodeBinaryPath(), + "plugin", + "-i", + plugin, + ]); } } return true; @@ -76,33 +89,57 @@ class LeetCodeExecutor implements Disposable { } public async signOut(): Promise { - return await await this.executeCommandEx(this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "user", "-L"]); + return await await this.executeCommandEx(this.nodeExecutable, [ + await this.getLeetCodeBinaryPath(), + "user", + "-L", + ]); } public async listProblems(showLocked: boolean): Promise { - return await this.executeCommandEx(this.nodeExecutable, showLocked ? - [await this.getLeetCodeBinaryPath(), "list"] : - [await this.getLeetCodeBinaryPath(), "list", "-q", "L"], + return await this.executeCommandEx( + this.nodeExecutable, + showLocked + ? [await this.getLeetCodeBinaryPath(), "list"] + : [await this.getLeetCodeBinaryPath(), "list", "-q", "L"], ); } - public async showProblem(problemNode: IProblem, language: string, filePath: string, showDescriptionInComment: boolean = false): Promise { + public async showProblem( + problemNode: IProblem, + language: string, + filePath: string, + showDescriptionInComment: boolean = false, + ): Promise { const templateType: string = showDescriptionInComment ? "-cx" : "-c"; - if (!await fse.pathExists(filePath)) { + if (!(await fse.pathExists(filePath))) { await fse.createFile(filePath); - const codeTemplate: string = await this.executeCommandWithProgressEx("Fetching problem data...", this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "show", problemNode.id, templateType, "-l", language]); + const codeTemplate: string = await this.executeCommandWithProgressEx( + "Fetching problem data...", + this.nodeExecutable, + [await this.getLeetCodeBinaryPath(), "show", problemNode.id, templateType, "-l", language], + ); await fse.writeFile(filePath, codeTemplate); } } public async showSolution(input: string, language: string): Promise { - const solution: string = await this.executeCommandWithProgressEx("Fetching top voted solution from discussions...", this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "show", input, "--solution", "-l", language]); + const solution: string = await this.executeCommandWithProgressEx( + "Fetching top voted solution from discussions...", + this.nodeExecutable, + [await this.getLeetCodeBinaryPath(), "show", input, "--solution", "-l", language], + ); return solution; } public async getDescription(problemNodeId: string): Promise { - return await this.executeCommandWithProgressEx("Fetching problem description...", this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "show", problemNodeId, "-x"]); + return await this.executeCommandWithProgressEx("Fetching problem description...", this.nodeExecutable, [ + await this.getLeetCodeBinaryPath(), + "show", + problemNodeId, + "-x", + ]); } public async listSessions(): Promise { @@ -110,20 +147,40 @@ class LeetCodeExecutor implements Disposable { } public async enableSession(name: string): Promise { - return await this.executeCommandEx(this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "session", "-e", name]); + return await this.executeCommandEx(this.nodeExecutable, [ + await this.getLeetCodeBinaryPath(), + "session", + "-e", + name, + ]); } public async createSession(id: string): Promise { - return await this.executeCommandEx(this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "session", "-c", id]); + return await this.executeCommandEx(this.nodeExecutable, [ + await this.getLeetCodeBinaryPath(), + "session", + "-c", + id, + ]); } public async deleteSession(id: string): Promise { - return await this.executeCommandEx(this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "session", "-d", id]); + return await this.executeCommandEx(this.nodeExecutable, [ + await this.getLeetCodeBinaryPath(), + "session", + "-d", + id, + ]); } public async submitSolution(filePath: string): Promise { + const newPath: string = await getUnstubedFile(filePath); try { - return await this.executeCommandWithProgressEx("Submitting to LeetCode...", this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "submit", `"${filePath}"`]); + return await this.executeCommandWithProgressEx("Submitting to LeetCode...", this.nodeExecutable, [ + await this.getLeetCodeBinaryPath(), + "submit", + `"${newPath}"`, + ]); } catch (error) { if (error.result) { return error.result; @@ -133,19 +190,40 @@ class LeetCodeExecutor implements Disposable { } public async testSolution(filePath: string, testString?: string): Promise { + const newPath: string = await getUnstubedFile(filePath); if (testString) { - return await this.executeCommandWithProgressEx("Submitting to LeetCode...", this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "test", `"${filePath}"`, "-t", `${testString}`]); + return await this.executeCommandWithProgressEx("Submitting to LeetCode...", this.nodeExecutable, [ + await this.getLeetCodeBinaryPath(), + "test", + `"${newPath}"`, + "-t", + `${testString}`, + ]); } - return await this.executeCommandWithProgressEx("Submitting to LeetCode...", this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "test", `"${filePath}"`]); + return await this.executeCommandWithProgressEx("Submitting to LeetCode...", this.nodeExecutable, [ + await this.getLeetCodeBinaryPath(), + "test", + `"${newPath}"`, + ]); } public async switchEndpoint(endpoint: string): Promise { switch (endpoint) { case Endpoint.LeetCodeCN: - return await this.executeCommandEx(this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "plugin", "-e", "leetcode.cn"]); + return await this.executeCommandEx(this.nodeExecutable, [ + await this.getLeetCodeBinaryPath(), + "plugin", + "-e", + "leetcode.cn", + ]); case Endpoint.LeetCode: default: - return await this.executeCommandEx(this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "plugin", "-d", "leetcode.cn"]); + return await this.executeCommandEx(this.nodeExecutable, [ + await this.getLeetCodeBinaryPath(), + "plugin", + "-d", + "leetcode.cn", + ]); } } @@ -157,7 +235,10 @@ class LeetCodeExecutor implements Disposable { await this.executeCommandWithProgressEx("Updating the favorite list...", "node", commandParams); } - public async getCompaniesAndTags(): Promise<{ companies: { [key: string]: string[] }, tags: { [key: string]: string[] } }> { + public async getCompaniesAndTags(): Promise<{ + companies: { [key: string]: string[] }; + tags: { [key: string]: string[] }; + }> { // preprocess the plugin source const companiesTagsPath: string = path.join(this.leetCodeRootPath, "lib", "plugins", "company.js"); const companiesTagsSrc: string = (await fse.readFile(companiesTagsPath, "utf8")).replace( @@ -181,14 +262,23 @@ class LeetCodeExecutor implements Disposable { return extensionConfig.get("nodePath", "node" /* default value */); } - private async executeCommandEx(command: string, args: string[], options: cp.SpawnOptions = { shell: true }): Promise { + private async executeCommandEx( + command: string, + args: string[], + options: cp.SpawnOptions = { shell: true }, + ): Promise { if (wsl.useWsl()) { return await executeCommand("wsl", [command].concat(args), options); } return await executeCommand(command, args, options); } - private async executeCommandWithProgressEx(message: string, command: string, args: string[], options: cp.SpawnOptions = { shell: true }): Promise { + private async executeCommandWithProgressEx( + message: string, + command: string, + args: string[], + options: cp.SpawnOptions = { shell: true }, + ): Promise { if (wsl.useWsl()) { return await executeCommandWithProgress(message, "wsl", [command].concat(args), options); } diff --git a/src/utils/problemUtils.ts b/src/utils/problemUtils.ts index d2dcc3ed..e4ab7b06 100644 --- a/src/utils/problemUtils.ts +++ b/src/utils/problemUtils.ts @@ -1,36 +1,123 @@ -// Copyright (c) jdneo. All rights reserved. -// Licensed under the MIT license. - -import * as fse from "fs-extra"; -import * as _ from "lodash"; -import * as path from "path"; -import { IProblem, langExt } from "../shared"; - -export function genFileExt(language: string): string { - const ext: string | undefined = langExt.get(language); - if (!ext) { - throw new Error(`The language "${language}" is not supported.`); - } - return ext; -} - -export function genFileName(node: IProblem, language: string): string { - const slug: string = _.kebabCase(node.name); - const ext: string = genFileExt(language); - return `${node.id}.${slug}.${ext}`; -} - -export async function getNodeIdFromFile(fsPath: string): Promise { - const fileContent: string = await fse.readFile(fsPath, "utf8"); - let id: string = ""; - const matchResults: RegExpMatchArray | null = fileContent.match(/@lc.+id=(.+?) /); - if (matchResults && matchResults.length === 2) { - id = matchResults[1]; - } - // Try to get id from file name if getting from comments failed - if (!id) { - id = path.basename(fsPath).split(".")[0]; - } - - return id; -} +// Copyright (c) jdneo. All rights reserved. +// Licensed under the MIT license. + +import * as fse from "fs-extra"; +import * as _ from "lodash"; +import * as path from "path"; +import * as vscode from "vscode"; +import { extensionState } from "../extensionState"; +import { IProblem, langExt } from "../shared"; +import { isWindows, usingCmd } from "./osUtils"; +import { useWsl } from "./wslUtils"; + +const fileMateReg: RegExp = /@lc\s+(?:[\s\S]*?)\s+id=(\d+)\s+lang=([\S]+)/; + +const beforeStubReg: RegExp = /@before-stub-for-debug-begin([\s\S]*?)@before-stub-for-debug-end/; +const afterStubReg: RegExp = /@after-stub-for-debug-begin([\s\S]*?)@after-stub-for-debug-end/; + +export function genFileExt(language: string): string { + const ext: string | undefined = langExt.get(language); + if (!ext) { + throw new Error(`The language "${language}" is not supported.`); + } + return ext; +} + +export function genFileName(node: IProblem, language: string): string { + const slug: string = _.kebabCase(node.name); + const ext: string = genFileExt(language); + return `${node.id}.${slug}.${ext}`; +} + +export async function getNodeIdFromFile(fsPath: string): Promise { + const fileContent: string = await fse.readFile(fsPath, "utf8"); + let id: string = ""; + const matchResults: RegExpMatchArray | null = fileContent.match(/@lc.+id=(.+?) /); + if (matchResults && matchResults.length === 2) { + id = matchResults[1]; + } + // Try to get id from file name if getting from comments failed + if (!id) { + id = path.basename(fsPath).split(".")[0]; + } + + return id; +} + +export function fileMeta(content: string): { id: string; lang: string } | null { + const result: RegExpExecArray | null = fileMateReg.exec(content); + if (result != null) { + return { + id: result[1], + lang: result[2], + }; + } + return null; +} + +export async function getUnstubedFile(filePath: string): Promise { + const content: string = (await fse.readFile(filePath)).toString(); + const stripped: string = content.replace(beforeStubReg, "").replace(afterStubReg, ""); + + if (content.length === stripped.length) { + // no stub, return original filePath + return filePath; + } + + const meta: { id: string; lang: string } | null = fileMeta(content); + if (meta == null) { + vscode.window.showErrorMessage( + "File meta info has been changed, please check the content: '@lc app=leetcode.cn id=xx lang=xx'.", + ); + throw new Error(""); + } + + const newPath: string = path.join(extensionState.cachePath, `${meta.id}-${meta.lang}`); + await fse.writeFile(newPath, stripped); + return newPath; +} + +async function getProblemSpecialCode( + language: string, + problem: string, + fileExt: string, + extDir: string, +): Promise { + const problemPath: string = path.join(extDir, "src/debug/entry", language, "problems", `${problem}.${fileExt}`); + const isSpecial: boolean = await fse.pathExists(problemPath); + if (isSpecial) { + const specialContent: Buffer = await fse.readFile(problemPath); + return specialContent.toString(); + } + const fileContent: Buffer = await fse.readFile( + path.join(extDir, "src/debug/entry", language, "problems", `common.${fileExt}`), + ); + return fileContent.toString(); +} + +export async function getEntryFile(language: string, problem: string): Promise { + const extDir: string = vscode.extensions.getExtension("shengchen.vscode-leetcode")!.extensionPath; + const fileExt: string = genFileExt(language); + const specialCode: string = await getProblemSpecialCode(language, problem, fileExt, extDir); + const tmpEntryCode: string = ( + await fse.readFile(path.join(extDir, "src/debug/entry", language, `entry.${fileExt}`)) + ).toString(); + const entryCode: string = tmpEntryCode.replace(/\/\/ @@stub-for-code@@/, specialCode); + const entryPath: string = path.join(extensionState.cachePath, `${language}problem${problem}.${fileExt}`); + await fse.writeFile(entryPath, entryCode); + return entryPath; +} + +export function parseTestString(test: string): string { + if (useWsl() || !isWindows()) { + return `'${test}'`; + } + + // In windows and not using WSL + if (usingCmd()) { + return `"${test.replace(/"/g, '\\"')}"`; + } else { + // Assume using PowerShell + return `'${test.replace(/"/g, '\\"')}'`; + } +} diff --git a/src/utils/workspaceUtils.ts b/src/utils/workspaceUtils.ts index c129f8db..39b77e97 100644 --- a/src/utils/workspaceUtils.ts +++ b/src/utils/workspaceUtils.ts @@ -1,6 +1,7 @@ // Copyright (c) jdneo. All rights reserved. // Licensed under the MIT license. +import * as fs from "fs"; import * as os from "os"; import * as path from "path"; import * as vscode from "vscode"; @@ -41,13 +42,23 @@ export async function selectWorkspaceFolder(): Promise { case OpenOption.justOpenFile: return workspaceFolderSetting; case OpenOption.openInCurrentWindow: - await vscode.commands.executeCommand("vscode.openFolder", vscode.Uri.file(workspaceFolderSetting), false); + await vscode.commands.executeCommand( + "vscode.openFolder", + vscode.Uri.file(workspaceFolderSetting), + false, + ); return ""; case OpenOption.openInNewWindow: - await vscode.commands.executeCommand("vscode.openFolder", vscode.Uri.file(workspaceFolderSetting), true); + await vscode.commands.executeCommand( + "vscode.openFolder", + vscode.Uri.file(workspaceFolderSetting), + true, + ); return ""; case OpenOption.addToWorkspace: - vscode.workspace.updateWorkspaceFolders(workspaceFolders.length, 0, { uri: vscode.Uri.file(workspaceFolderSetting) }); + vscode.workspace.updateWorkspaceFolders(workspaceFolders.length, 0, { + uri: vscode.Uri.file(workspaceFolderSetting), + }); break; default: return ""; @@ -68,7 +79,7 @@ export async function getActiveFilePath(uri?: vscode.Uri): Promise { value: ":browse", }, ); - const choice: IQuickItemEx | undefined = await vscode.window.showQuickPick( - picks, - { placeHolder: "Select where you would like to save your LeetCode files" }, - ); + const choice: IQuickItemEx | undefined = await vscode.window.showQuickPick(picks, { + placeHolder: "Select where you would like to save your LeetCode files", + }); if (!choice) { result = ""; } else if (choice.value === ":browse") { @@ -125,3 +135,9 @@ enum OpenOption { openInNewWindow = "Open in new window", addToWorkspace = "Add to workspace", } + +export function checkCachePath(globalStoragePath: string): void { + if (!fs.existsSync(globalStoragePath)) { + fs.mkdirSync(globalStoragePath); + } +}