Skip to content

Commit 6f8ae6d

Browse files
JackieHooJackieHoo
JackieHoo
authored and
JackieHoo
committed
add 409
1 parent f24e7f0 commit 6f8ae6d

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

205.md

+5
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
# Isomorphic Strings
2+
### 解法一
3+
4+
```go
5+
6+
```

409.md

+22
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
11
# Longest Palindrome
2+
3+
### 解法一
4+
```go
5+
func longestPalindrome(s string) int {
6+
if len(s) == 0 { // 判断零值
7+
return 0
8+
}
9+
result := 0
10+
mi := make(map[rune]int) // 使用额外的数据结构
11+
for _,v := range s {
12+
mi[v]++
13+
}
14+
15+
for _,v := range mi {
16+
result += (v/2)*2// 无论是奇数既或者是偶数用 v/2 * 2 都是取出来的偶数个。
17+
}
18+
if result < len(s) { // 就是偶数个都找到了,如果有多的几个奇数,那么取出来一个放到中间即可。
19+
result +=1
20+
}
21+
return result
22+
}
23+
```

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All leetcode questions that solved in different methods.
55
|question number|URL|type|result|
66
|:---:|:---:|:---:|:---:|
77
|[9](./9.md)|[Palindrome Number](https://leetcode-cn.com/problems/palindrome-number/description/)|string|😯|
8-
|[205](./205.md)|[Isomorphic Strings](https://leetcode-cn.com/problems/isomorphic-strings/description/)|string|😯|
8+
|[205](./205.md)|[Isomorphic Strings](https://leetcode-cn.com/problems/isomorphic-strings/description/)|string|👌|
99
|[240](./240.md)|[Search a 2D Matrix II](https://leetcode-cn.com/problems/search-a-2d-matrix-ii/description/)|array|👌|
1010
|[242](./242.md)|[Valid Anagram](https://leetcode-cn.com/problems/valid-anagram/description/)|string|👌|
1111
|[283](./283.md)|[Move Zeroes](https://leetcode-cn.com/problems/move-zeroes/description/)|array|👌|

0 commit comments

Comments
 (0)