Files
leetcode/top-100-liked/93/leetcode_test.go
T
2026-07-23 16:56:50 +08:00

45 lines
901 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package top100liked
import (
"testing"
)
// https://leetcode.cn/problems/longest-palindromic-substring/?envType=study-plan-v2&envId=top-100-liked
// 5. 最长回文子串
//
// 给你一个字符串 `s`,找到 `s` 中最长的 回文 子串。
// 示例 1
// 输入:s = "babad"
// 输出:"bab"
// 解释:"aba" 同样是符合题意的答案。
// 示例 2
// 输入:s = "cbbd"
// 输出:"bb"
//
// 提示:
// - `1 <= s.length <= 1000`
// - `s` 仅由数字和英文字母组成
//
func longestPalindrome(s string) string {
}
func TestLongestPalindrome(t *testing.T) {
cases := []struct {
name string
s string
want string
}{
{"example1", "babad", "bab"},
{"example2", "cbbd", "bb"},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
got := longestPalindrome(c.s)
if got != c.want {
t.Errorf("got %v, want %v", got, c.want)
}
})
}
}