Skip to content

Commit 6b6875b

Browse files
feat: search standard on word
1 parent 106015d commit 6b6875b

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

resolved/search-standard-on-word.go

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package resolved
2+
3+
func SearchStandardOnWord(word string, errorsQtt int) bool {
4+
const MINIMUN_LENGTH = 1
5+
6+
if word == "" || len(word) == MINIMUN_LENGTH {
7+
return false
8+
}
9+
10+
hashtable := make(map[string]int)
11+
12+
for _, character := range word {
13+
char := string(character)
14+
15+
/*****
16+
if _, ok := hashtable[char]; ok {
17+
hashtable[char]++
18+
} else {
19+
hashtable[char] = 1
20+
}
21+
is similar to \/
22+
**/
23+
24+
hashtable[char]++
25+
}
26+
27+
equalCharsQt := hashtable[string(word[0])]
28+
29+
errors := 0
30+
31+
for _, val := range hashtable {
32+
if val != equalCharsQt {
33+
errors++
34+
if errors > errorsQtt {
35+
return false
36+
}
37+
}
38+
}
39+
return true
40+
}

0 commit comments

Comments
 (0)