Skip to content

Commit 4d50f69

Browse files
author
openset
committed
v1.4.9
1 parent a1f4780 commit 4d50f69

File tree

1,974 files changed

+1988
-1974
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,974 files changed

+1988
-1974
lines changed

internal/base/base.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ import (
1313
"sync"
1414
)
1515

16+
// CmdName
1617
const CmdName = "leetcode"
1718

1819
var (
1920
Commands []*Command
2021
Mutex sync.Mutex
2122
)
2223

24+
// Command
2325
type Command struct {
2426
Run func(cmd *Command, args []string)
2527
UsageLine string

internal/leetcode/question_data.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func (question *questionType) LeetCodeUrl() string {
208208
}
209209

210210
func (question *questionType) PackageName() string {
211-
return "problem_" + question.QuestionFrontendId
211+
return "problem" + question.QuestionFrontendId
212212
}
213213

214214
func (question *questionType) SaveCodeSnippet() {
@@ -234,7 +234,7 @@ func (question *questionType) SaveCodeSnippet() {
234234
for _, lang := range langSupport {
235235
if code, ok := codeSet[lang.slug]; ok {
236236
lang.handle(question, code)
237-
break
237+
return
238238
}
239239
}
240240
}
@@ -255,6 +255,18 @@ func (question *questionType) saveMysqlSchemas() {
255255
filePutContents(question.getFilePath("mysql_schemas.sql"), buf.Bytes())
256256
}
257257

258+
func (question *questionType) RenamePackageName() {
259+
packageName := fmt.Sprintf("package %s", question.PackageName())
260+
reg := regexp.MustCompile(`package \w+`)
261+
for _, ext := range [...]string{".go", "_test.go"} {
262+
cts := fileGetContents(question.getFilePath(question.TitleSnake() + ext))
263+
if len(cts) > 0 {
264+
content := reg.ReplaceAllString(string(cts), packageName)
265+
question.saveCodeContent(content, ext)
266+
}
267+
}
268+
}
269+
258270
func handleCodeGolang(question *questionType, code codeSnippetsType) {
259271
content := fmt.Sprintf("package %s\n\n", question.PackageName())
260272
content += code.Code + "\n"

internal/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/openset/leetcode/internal/base"
99
)
1010

11-
const version = "1.4.8"
11+
const version = "1.4.9"
1212

1313
var CmdVersion = &base.Command{
1414
Run: runVersion,

problems/01-matrix/01_matrix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package problem_542
1+
package problem542
22

33
func updateMatrix(matrix [][]int) [][]int {
44
m, n := len(matrix), len(matrix[0])

problems/01-matrix/01_matrix_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package problem_542
1+
package problem542
22

33
import (
44
"reflect"

problems/1-bit-and-2-bit-characters/1_bit_and_2_bit_characters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package problem_717
1+
package problem717
22

33
func isOneBitCharacter(bits []int) bool {
44
i, l := 0, len(bits)-1

problems/1-bit-and-2-bit-characters/1_bit_and_2_bit_characters_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package problem_717
1+
package problem717
22

33
import "testing"
44

problems/132-pattern/132_pattern.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package problem_456
1+
package problem456
22

33
func find132pattern(nums []int) bool {
44
ak, ajStack := -1<<31, make([]int, 0, len(nums))

problems/132-pattern/132_pattern_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package problem_456
1+
package problem456
22

33
import "testing"
44

problems/2-keys-keyboard/2_keys_keyboard.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package problem_650
1+
package problem650
22

33
func minSteps(n int) int {
44
if n == 1 {

0 commit comments

Comments
 (0)