forked from halfrost/LeetCode-Go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatistic.go
42 lines (39 loc) · 1.37 KB
/
statistic.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"sort"
m "github.com/halfrost/LeetCode-Go/ctl/models"
"github.com/halfrost/LeetCode-Go/ctl/util"
)
func statisticalData(problemsMap map[int]m.StatStatusPairs, solutionIds []int) (easyTotal, mediumTotal, hardTotal, optimizingEasy, optimizingMedium, optimizingHard int32, optimizingIds []int) {
easyTotal, mediumTotal, hardTotal, optimizingEasy, optimizingMedium, optimizingHard, optimizingIds = 0, 0, 0, 0, 0, 0, []int{}
for _, v := range problemsMap {
switch m.DifficultyMap[v.Difficulty.Level] {
case "Easy":
{
easyTotal++
if v.Status == "ac" && util.BinarySearch(solutionIds, int(v.Stat.FrontendQuestionID)) == -1 {
optimizingEasy++
optimizingIds = append(optimizingIds, int(v.Stat.FrontendQuestionID))
}
}
case "Medium":
{
mediumTotal++
if v.Status == "ac" && util.BinarySearch(solutionIds, int(v.Stat.FrontendQuestionID)) == -1 {
optimizingMedium++
optimizingIds = append(optimizingIds, int(v.Stat.FrontendQuestionID))
}
}
case "Hard":
{
hardTotal++
if v.Status == "ac" && util.BinarySearch(solutionIds, int(v.Stat.FrontendQuestionID)) == -1 {
optimizingHard++
optimizingIds = append(optimizingIds, int(v.Stat.FrontendQuestionID))
}
}
}
}
sort.Ints(optimizingIds)
return easyTotal, mediumTotal, hardTotal, optimizingEasy, optimizingMedium, optimizingHard, optimizingIds
}