mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-20 05:33:53 +08:00
Merge pull request #60 from halfrost/code_quality_improvement
optimization code quality level from A to A+
This commit is contained in:
@ -53,7 +53,7 @@ func calculate1(s string) int {
|
||||
break
|
||||
}
|
||||
}
|
||||
tmp = string(stack[index+1 : len(stack)])
|
||||
tmp = string(stack[index+1:])
|
||||
stack = stack[:index]
|
||||
res := strconv.Itoa(calculateStr(tmp))
|
||||
for j := 0; j < len(res); j++ {
|
||||
@ -98,7 +98,6 @@ func calculateStr(str string) int {
|
||||
if tmpStr != "" {
|
||||
num, _ := strconv.Atoi(tmpStr)
|
||||
nums = append(nums, num)
|
||||
tmpStr = ""
|
||||
}
|
||||
res = nums[0]
|
||||
for i := 0; i < len(s); i++ {
|
||||
|
@ -26,21 +26,21 @@ func Test_Problem224(t *testing.T) {
|
||||
|
||||
qs := []question224{
|
||||
|
||||
question224{
|
||||
{
|
||||
para224{"1 + 1"},
|
||||
ans224{2},
|
||||
},
|
||||
question224{
|
||||
{
|
||||
para224{" 2-1 + 2 "},
|
||||
ans224{3},
|
||||
},
|
||||
|
||||
question224{
|
||||
{
|
||||
para224{"(1+(4+5+2)-3)+(6+8)"},
|
||||
ans224{23},
|
||||
},
|
||||
|
||||
question224{
|
||||
{
|
||||
para224{"2-(5-6)"},
|
||||
ans224{3},
|
||||
},
|
||||
|
Reference in New Issue
Block a user