1.4.10
commit: df4b2bdcf67f5fbefc646987389a838ca3224329
built at: 2024-11-04T11:55:18Z
goos: darwin
goarch: amd64
Home dir : /Users/xxx/.config/leetgo
Project root : /Users/xxx/go/src/leetcode-2024
Working dir : /Users/xxx/go/src/leetcode-2024/go
Project config file : /Users/xxx/go/src/leetcode-2024/leetgo.yaml
Project configuration:
# Leetgo configuration file, see more at https://github.com/j178/leetgo
# Your name
author: Abirdcfly
# Language of the question description: 'zh' (Simplified Chinese) or 'en' (English).
language: zh
code:
# Language of code generated for questions: go, cpp, python, java...
# (will be overridden by command line flag -l/--lang).
lang: go
# The default template to generate filename (without extension), e.g. {{.Id}}.{{.Slug}}
# Available attributes: Id, Slug, Title, Difficulty, Lang, SlugIsMeaningful
# (Most questions have descriptive slugs, but some consist of random characters. The SlugIsMeaningful boolean indicates whether a slug is meaningful.)
# Available functions: lower, upper, trim, padWithZero, toUnderscore, group.
filename_template: '{{ .Id | padWithZero 4 }}{{ if .SlugIsMeaningful }}.{{ .Slug }}{{ end }}'
# Generate question description into a separate question.md file, otherwise it will be embed in the code file.
separate_description_file: true
# Default modifiers for all languages.
modifiers:
- name: removeUselessComments
go:
# Base directory to put generated questions, defaults to the language slug, e.g. go, python, cpp.
out_dir: go
# Functions that modify the generated code.
modifiers:
- name: removeUselessComments
- name: changeReceiverName
- name: addNamedReturn
- name: addMod
python3:
# Base directory to put generated questions, defaults to the language slug, e.g. go, python, cpp.
out_dir: python
# Path to the python executable that creates the venv.
executable: python3
cpp:
# Base directory to put generated questions, defaults to the language slug, e.g. go, python, cpp.
out_dir: cpp
# C++ compiler
cxx: g++
# C++ compiler flags (our Leetcode I/O library implementation requires C++17).
cxxflags: -O2 -std=c++17
rust:
# Base directory to put generated questions, defaults to the language slug, e.g. go, python, cpp.
out_dir: rust
java:
# Base directory to put generated questions, defaults to the language slug, e.g. go, python, cpp.
out_dir: java
leetcode:
# LeetCode site, https://leetcode.com or https://leetcode.cn
site: https://leetcode.cn
# Credentials to access LeetCode.
credentials:
# How to provide credentials: browser, cookies, password or none.
from: browser
# Browsers to get cookies from: chrome, safari, edge or firefox. If empty, all browsers will be tried. Only used when 'from' is 'browser'.
browsers: []
contest:
# Base directory to put generated contest questions.
out_dir: contest
# Template to generate filename of the question.
filename_template: '{{ .ContestShortSlug }}/{{ .Id }}{{ if .SlugIsMeaningful }}.{{ .Slug }}{{ end }}'
# Open the contest page in browser after generating.
open_in_browser: true
# Editor settings to open generated files.
editor:
# Use a predefined editor: vim, vscode, goland
# Set to 'none' to disable, set to 'custom' to provide your own command and args.
use: custom
# Custom command to open files.
command: "idea"
# Arguments to your custom command.
# String contains {{.CodeFile}}, {{.TestFile}}, {{.DescriptionFile}}, {{.TestCasesFile}} will be replaced with corresponding file path.
# {{.Folder}} will be substituted with the output directory.
# {{.Files}} will be substituted with the list of all file paths.
args: "{{.Folder}}"
2024/11/06 21:17:51 DEBU cache loaded path=/Users/xxx/.config/leetgo/cache/leetcode-questions.json elapsed=56.584337ms
2024/11/06 21:17:51 DEBU get by id elapsed=56.901307ms
2024/11/06 21:17:51 DEBU reading cookies browser=safari file=/Users/xxx/Library/Cookies/Cookies.binarycookies
2024/11/06 21:17:51 DEBU reading cookies browser=chrome file="/Users/xxx/Library/Application Support/Google/Chrome/Default/Network/Cookies"
2024/11/06 21:17:51 DEBU reading cookies browser=chrome file="/Users/xxx/Library/Application Support/Google/Chrome/Default/Cookies"
2024/11/06 21:17:51 INFO reading leetcode cookies browser=chrome domain=leetcode.cn
2024/11/06 21:17:51 DEBU finished reading cookies elapsed=75.348871ms
2024/11/06 21:17:51 DEBU request method=POST url=https://leetcode.cn/graphql
body=
│ {"operationName":"","query":"\nquery globalData {\n userStatus {\n isSignedIn\n username\n realName\n userSlug\n avatar\n activeSessionId\n\tisPremium\n }\n}","variables":{}}
2024/11/06 21:17:51 DEBU response url=https://leetcode.cn/graphql code=200
headers=
│ Connection: keep-alive\r
│ Content-Length: 249\r
│ Content-Type: application/json\r
data="{\"data\":{\"userStatus\":{\"isSignedIn\":true,\"username\":\"abirdcfly\",\"realName\":\"Abirdcfly\",\"userSlug\":\"abirdcfly\",\"avatar\":\"https://assets.leetcode.cn/aliyun-lc-upload/users/abirdcfly/avatar_1566990570.png\",\"activeSessionId\":3483173,\"isPremium\":false}}}"
2024/11/06 21:17:51 INFO running test locally question=string-compression
2024/11/06 21:17:51 DEBU request method=POST url=https://leetcode.cn/graphql
body=
│ {"operationName":"questionData","query":"\n\tquery questionData($titleSlug: String!) {\n\t\tquestion(titleSlug: $titleSlug) {\n\t\t\tquestionId\n\t\t\tquestionFrontendId\n\t\t\tcategoryTitle\n\t\t\ttitle\n\t\t\ttitleSlug\n\t\t\tcontent\n\t\t\tisPaidOnly\n\t\t\ttranslatedTitle\n\t\t\ttranslatedContent\n\t\t\tdifficulty\n\t\t\tstatus\n\t\t\tstats\n\t\t\thints\n\t\t\tsimilarQuestions\n\t\t\tsampleTestCase\n\t\t\texampleTestcases\n\t\t\texampleTestcaseList\n\t\t\tjsonExampleTestcases\n\t\t\tmetaData\n\t\t\tcodeSnippets {\n\t\t\t\tlang\n\t\t\t\tlangSlug\n\t\t\t\tcode\n\t\t\t}\n\t\t\ttopicTags {\n\t\t\t\tname\n\t\t\t\tslug\n\t\t\t\ttranslatedName\n\t\t\t}\n\t\t\teditorType\n\t\t}\n\t}","variables":{"titleSlug":"string-compression"}}
2024/11/06 21:17:51 DEBU response url=https://leetcode.cn/graphql code=200
headers=
│ Connection: keep-alive\r
│ Content-Encoding: gzip\r
│ Content-Type: application/json\r
data="{\"data\":{\"question\":{\"questionId\":\"443\",\"questionFrontendId\":\"443\",\"categoryTitle\":\"Algorithms\",\"title\":\"String Compression\",\"titleSlug\":\"string-compression\",\"content\":\"<p>Given an array of characters <code>chars</code>, compress it using the following algorithm:</p>\n\n<p>Begin with an empty string <code>s</code>. For each group of <strong>consecutive repeating characters</strong> in <code>chars</code>:</p>\n\n<ul>\n\t<li>If the group's length is <code>1</code>, append the character to <code>s</code>.</li>\n\t<li>Otherwise, append the character followed by the group's length.</li>\n</ul>\n\n<p>The compressed string <code>s</code> <strong>should not be returned separately</strong>, but instead, be stored <strong>in the input character array <code>chars</code></strong>. Note that group lengths that are <code>10</code> or longer will be split into multiple characters in <code>chars</code>.</p>\n\n<p>After you are done <strong>modifying the input array,</strong> return <em>the new length of the array</em>.</p>\n\n<p>You must write an algorithm that uses only constant extra space.</p>\n\n<p> </p>\n<p><strong class=\\"example\\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> chars = ["a","a","b","b","c","c","c"]\n<strong>Output:</strong> Return 6, and the first 6 characters of the input array should be: ["a","2","b","2","c","3"]\n<strong>Explanation:</strong> The groups are "aa", "bb", and "ccc". This compresses to "a2b2c3".\n</pre>\n\n<p><strong class=\\"example\\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> chars = ["a"]\n<strong>Output:</strong> Return 1, and the first character of the input array should be: ["a"]\n<strong>Explanation:</strong> The only group is "a", which remains uncompressed since it's a single character.\n</pre>\n\n<p><strong class=\\"example\\">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> chars = ["a","b","b","b","b","b","b","b","b","b","b","b","b"]\n<strong>Output:</strong> Return 4, and the first 4 characters of the input array should be: ["a","b","1","2"].\n<strong>Explanation:</strong> The groups are "a" and "bbbbbbbbbbbb". This compresses to "ab12".</pre>\n\n<p> </p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>1 <= chars.length <= 2000</code></li>\n\t<li><code>chars[i]</code> is a lowercase English letter, uppercase English letter, digit, or symbol.</li>\n</ul>\n\",\"isPaidOnly\":false,\"translatedTitle\":\"\u538b\u7f29\u5b57\u7b26\u4e32\",\"translatedContent\":\"<p>\u7ed9\u4f60\u4e00\u4e2a\u5b57\u7b26\u6570\u7ec4 <code>chars</code> \uff0c\u8bf7\u4f7f\u7528\u4e0b\u8ff0\u7b97\u6cd5\u538b\u7f29\uff1a</p>\n\n<p>\u4ece\u4e00\u4e2a\u7a7a\u5b57\u7b26\u4e32 <code>s</code> \u5f00\u59cb\u3002\u5bf9\u4e8e <code>chars</code> \u4e2d\u7684\u6bcf\u7ec4 <strong>\u8fde\u7eed\u91cd\u590d\u5b57\u7b26</strong> \uff1a</p>\n\n<ul>\n\t<li>\u5982\u679c\u8fd9\u4e00\u7ec4\u957f\u5ea6\u4e3a <code>1</code> \uff0c\u5219\u5c06\u5b57\u7b26\u8ffd\u52a0\u5230 <code>s</code> \u4e2d\u3002</li>\n\t<li>\u5426\u5219\uff0c\u9700\u8981\u5411 <code>s</code> \u8ffd\u52a0\u5b57\u7b26\uff0c\u540e\u8ddf\u8fd9\u4e00\u7ec4\u7684\u957f\u5ea6\u3002</li>\n</ul>\n\n<p>\u538b\u7f29\u540e\u5f97\u5230\u7684\u5b57\u7b26\u4e32 <code>s</code> <strong>\u4e0d\u5e94\u8be5\u76f4\u63a5\u8fd4\u56de</strong> \uff0c\u9700\u8981\u8f6c\u50a8\u5230\u5b57\u7b26\u6570\u7ec4 <code>chars</code> \u4e2d\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u7ec4\u957f\u5ea6\u4e3a <code>10</code> \u6216 <code>10</code> \u4ee5\u4e0a\uff0c\u5219\u5728 <code>chars</code> \u6570\u7ec4\u4e2d\u4f1a\u88ab\u62c6\u5206\u4e3a\u591a\u4e2a\u5b57\u7b26\u3002</p>\n\n<p>\u8bf7\u5728 <strong>\u4fee\u6539\u5b8c\u8f93\u5165\u6570\u7ec4\u540e</strong> \uff0c\u8fd4\u56de\u8be5\u6570\u7ec4\u7684\u65b0\u957f\u5ea6\u3002</p>\n\n<p>\u4f60\u5fc5\u987b\u8bbe\u8ba1\u5e76\u5b9e\u73b0\u4e00\u4e2a\u53ea\u4f7f\u7528\u5e38\u91cf\u989d\u5916\u7a7a\u95f4\u7684\u7b97\u6cd5\u6765\u89e3\u51b3\u6b64\u95ee\u9898\u3002</p>\n\n<p> </p>\n\n<p><strong>\u793a\u4f8b 1\uff1a</strong></p>\n\n<pre>\n<strong>\u8f93\u5165\uff1a</strong>chars = [\\"a\\",\\"a\\",\\"b\\",\\"b\\",\\"c\\",\\"c\\",\\"c\\"]\n<strong>\u8f93\u51fa\uff1a</strong>\u8fd4\u56de 6 \uff0c\u8f93\u5165\u6570\u7ec4\u7684\u524d 6 \u4e2a\u5b57\u7b26\u5e94\u8be5\u662f\uff1a[\\"a\\",\\"2\\",\\"b\\",\\"2\\",\\"c\\",\\"3\\"]\n<strong>\u89e3\u91ca\uff1a</strong>\\"aa\\" \u88ab \\"a2\\" \u66ff\u4ee3\u3002\\"bb\\" \u88ab \\"b2\\" \u66ff\u4ee3\u3002\\"ccc\\" \u88ab \\"c3\\" \u66ff\u4ee3\u3002\n</pre>\n\n<p><strong>\u793a\u4f8b 2\uff1a</strong></p>\n\n<pre>\n<strong>\u8f93\u5165\uff1a</strong>chars = [\\"a\\"]\n<strong>\u8f93\u51fa\uff1a</strong>\u8fd4\u56de 1 \uff0c\u8f93\u5165\u6570\u7ec4\u7684\u524d 1 \u4e2a\u5b57\u7b26\u5e94\u8be5\u662f\uff1a[\\"a\\"]\n<strong>\u89e3\u91ca\uff1a</strong>\u552f\u4e00\u7684\u7ec4\u662f\u201ca\u201d\uff0c\u5b83\u4fdd\u6301\u672a\u538b\u7f29\uff0c\u56e0\u4e3a\u5b83\u662f\u4e00\u4e2a\u5b57\u7b26\u3002\n</pre>\n\n<p><strong>\u793a\u4f8b 3\uff1a</strong></p>\n\n<pre>\n<strong>\u8f93\u5165\uff1a</strong>chars = [\\"a\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\"]\n<strong>\u8f93\u51fa\uff1a</strong>\u8fd4\u56de 4 \uff0c\u8f93\u5165\u6570\u7ec4\u7684\u524d 4 \u4e2a\u5b57\u7b26\u5e94\u8be5\u662f\uff1a[\\"a\\",\\"b\\",\\"1\\",\\"2\\"]\u3002\n<strong>\u89e3\u91ca\uff1a</strong>\u7531\u4e8e\u5b57\u7b26 \\"a\\" \u4e0d\u91cd\u590d\uff0c\u6240\u4ee5\u4e0d\u4f1a\u88ab\u538b\u7f29\u3002\\"bbbbbbbbbbbb\\" \u88ab \u201cb12\u201d \u66ff\u4ee3\u3002\n</pre>\n\n<p> </p>\n\n<p><strong>\u63d0\u793a\uff1a</strong></p>\n\n<ul>\n\t<li><code>1 <= chars.length <= 2000</code></li>\n\t<li><code>chars[i]</code> \u53ef\u4ee5\u662f\u5c0f\u5199\u82f1\u6587\u5b57\u6bcd\u3001\u5927\u5199\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u6216\u7b26\u53f7</li>\n</ul>\n\",\"difficulty\":\"Medium\",\"status\":\"ac\",\"stats\":\"{\\"totalAccepted\\": \\"111K\\", \\"totalSubmission\\": \\"224.4K\\", \\"totalAcceptedRaw\\": 111012, \\"totalSubmissionRaw\\": 224407, \\"acRate\\": \\"49.5%\\"}\",\"hints\":[\"How do you know if you are at the end of a consecutive group of characters?\"],\"similarQuestions\":\"[{\\"title\\": \\"Count and Say\\", \\"titleSlug\\": \\"count-and-say\\", \\"difficulty\\": \\"Medium\\", \\"translatedTitle\\": \\"\\u5916\\u89c2\\u6570\\u5217\\", \\"isPaidOnly\\": false}, {\\"title\\": \\"Encode and Decode Strings\\", \\"titleSlug\\": \\"encode-and-decode-strings\\", \\"difficulty\\": \\"Medium\\", \\"translatedTitle\\": \\"\\u5b57\\u7b26\\u4e32\\u7684\\u7f16\\u7801\\u4e0e\\u89e3\\u7801\\", \\"isPaidOnly\\": true}, {\\"title\\": \\"Design Compressed String Iterator\\", \\"titleSlug\\": \\"design-compressed-string-iterator\\", \\"difficulty\\": \\"Easy\\", \\"translatedTitle\\": \\"\\u8fed\\u4ee3\\u538b\\u7f29\\u5b57\\u7b26\\u4e32\\", \\"isPaidOnly\\": true}, {\\"title\\": \\"Decompress Run-Length Encoded List\\", \\"titleSlug\\": \\"decompress-run-length-encoded-list\\", \\"difficulty\\": \\"Easy\\", \\"translatedTitle\\": \\"\\u89e3\\u538b\\u7f29\\u7f16\\u7801\\u5217\\u8868\\", \\"isPaidOnly\\": false}, {\\"title\\": \\"String Compression III\\", \\"titleSlug\\": \\"string-compression-iii\\", \\"difficulty\\": \\"Medium\\", \\"translatedTitle\\": \\"\\u538b\\u7f29\\u5b57\\u7b26\\u4e32 III\\", \\"isPaidOnly\\": false}, {\\"title\\": \\"Better Compression of String\\", \\"titleSlug\\": \\"better-compression-of-string\\", \\"difficulty\\": \\"Medium\\", \\"translatedTitle\\": \\"\\u5b57\\u7b26\\u4e32\\u7684\\u66f4\\u597d\\u538b\\u7f29\\", \\"isPaidOnly\\": true}]\",\"sampleTestCase\":\"[\\"a\\",\\"a\\",\\"b\\",\\"b\\",\\"c\\",\\"c\\",\\"c\\"]\",\"exampleTestcases\":\"[\\"a\\",\\"a\\",\\"b\\",\\"b\\",\\"c\\",\\"c\\",\\"c\\"]\n[\\"a\\"]\n[\\"a\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\"]\",\"exampleTestcaseList\":[\"[\\"a\\",\\"a\\",\\"b\\",\\"b\\",\\"c\\",\\"c\\",\\"c\\"]\",\"[\\"a\\"]\",\"[\\"a\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\",\\"b\\"]\"],\"jsonExampleTestcases\":\"[\\"[\\\\"a\\\\",\\\\"a\\\\",\\\\"b\\\\",\\\\"b\\\\",\\\\"c\\\\",\\\\"c\\\\",\\\\"c\\\\"]\\", \\"[\\\\"a\\\\"]\\", \\"[\\\\"a\\\\",\\\\"b\\\\",\\\\"b\\\\",\\\\"b\\\\",\\\\"b\\\\",\\\\"b\\\\",\\\\"b\\\\",\\\\"b\\\\",\\\\"b\\\\",\\\\"b\\\\",\\\\"b\\\\",\\\\"b\\\\",\\\\"b\\\\"]\\"]\",\"metaData\":\"{\r\n \\"name\\": \\"compress\\",\r\n \\"params\\": [\r\n {\r\n \\"name\\": \\"chars\\",\r\n \\"type\\": \\"character[]\\"\r\n }\r\n ],\r\n \\"return\\": {\r\n \\"type\\": \\"integer\\"\r\n },\r\n \\"output\\": {\r\n \\"paramindex\\": 0,\r\n \\"size\\": \\"ret\\"\r\n }\r\n}\",\"codeSnippets\":[{\"lang\":\"C++\",\"langSlug\":\"cpp\",\"code\":\"class Solution {\npublic:\n int compress(vector<char>& chars) {\n \n }\n};\"},{\"lang\":\"Java\",\"langSlug\":\"java\",\"code\":\"class Solution {\n public int compress(char[] chars) {\n \n }\n}\"},{\"lang\":\"Python\",\"langSlug\":\"python\",\"code\":\"class Solution(object):\n def compress(self, chars):\n \\"\\"\\"\n :type chars: List[str]\n :rtype: int\n \\"\\"\\"\n \"},{\"lang\":\"Python3\",\"langSlug\":\"python3\",\"code\":\"class Solution:\n def compress(self, chars: List[str]) -> int:\n \"},{\"lang\":\"C\",\"langSlug\":\"c\",\"code\":\"int compress(char* chars, int charsSize) {\n \n}\"},{\"lang\":\"C#\",\"langSlug\":\"csharp\",\"code\":\"public class Solution {\n public int Compress(char[] chars) {\n \n }\n}\"},{\"lang\":\"JavaScript\",\"langSlug\":\"javascript\",\"code\":\"/**\n * @param {character[]} chars\n * @return {number}\n */\nvar compress = function(chars) {\n \n};\"},{\"lang\":\"TypeScript\",\"langSlug\":\"typescript\",\"code\":\"function compress(chars: string[]): number {\n \n};\"},{\"lang\":\"PHP\",\"langSlug\":\"php\",\"code\":\"class Solution {\n\n /**\n * @param String[] $chars\n * @return Integer\n */\n function compress(&$chars) {\n \n }\n}\"},{\"lang\":\"Swift\",\"langSlug\":\"swift\",\"code\":\"class Solution {\n func compress(_ chars: inout [Character]) -> Int {\n \n }\n}\"},{\"lang\":\"Kotlin\",\"langSlug\":\"kotlin\",\"code\":\"class Solution {\n fun compress(chars: CharArray): Int {\n \n }\n}\"..."
2024/11/06 21:17:51 INFO building cmd="/usr/local/bin/go build -o /var/folders/3v/mkwyck4x0f5bxv2gdv4_l8v00000gn/T/leetgo/string-compression-golang.exec /Users/xxx/go/src/leetcode-2024/go/0443.string-compression/solution.go"
2024/11/06 21:17:51 ERRO failed to run test locally err="invalid test case: case 0: cannot parse Return 6, and the first 6 characters of the input array should be: [\"a\",\"2\",\"b\",\"2\",\"c\",\"3\"] as integer"
input:
["a","a","b","b","c","c","c"]
output:
Return 6, and the first 6 characters of the input array should be: ["a","2","b","2","c","3"]
input:
["a"]
output:
Return 1, and the first character of the input array should be: ["a"]
input:
["a","b","b","b","b","b","b","b","b","b","b","b","b"]
output:
Return 4, and the first 4 characters of the input array should be: ["a","b","1","2"].
leetgo debug
Leetgo version info :
Home dir : /Users/xxx/.config/leetgo Project root : /Users/xxx/go/src/leetcode-2024 Working dir : /Users/xxx/go/src/leetcode-2024/go Project config file : /Users/xxx/go/src/leetcode-2024/leetgo.yaml Project configuration:
Full configuration :
Debug log
Description
should local tests be disabled if some LeetCode testcase results are described in natural language? like https://leetcode.cn/problems/string-compression