File tree 3 files changed +28
-1
lines changed
3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 1
1
# Isomorphic Strings
2
+ ### 解法一
3
+
4
+ ``` go
5
+
6
+ ```
Original file line number Diff line number Diff line change 1
1
# 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
+ ```
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ All leetcode questions that solved in different methods.
5
5
| question number| URL| type| result|
6
6
| :---:| :---:| :---:| :---:|
7
7
| [ 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| 👌 |
9
9
| [ 240] ( ./240.md ) | [ Search a 2D Matrix II] ( https://leetcode-cn.com/problems/search-a-2d-matrix-ii/description/ ) | array| 👌|
10
10
| [ 242] ( ./242.md ) | [ Valid Anagram] ( https://leetcode-cn.com/problems/valid-anagram/description/ ) | string| 👌|
11
11
| [ 283] ( ./283.md ) | [ Move Zeroes] ( https://leetcode-cn.com/problems/move-zeroes/description/ ) | array| 👌|
You can’t perform that action at this time.
0 commit comments