leetcode/include/s0005_longest_palindromic_substring.hpp

41 lines
1.1 KiB
C++
Raw Normal View History

2022-11-21 13:15:56 +00:00
#ifndef S0005_LONGEST_PALINDROMIC_SUBSTRING_HPP
#define S0005_LONGEST_PALINDROMIC_SUBSTRING_HPP
2022-11-02 09:32:58 +00:00
#include <algorithm>
2022-11-30 10:20:36 +00:00
#include <string>
2022-11-02 09:32:58 +00:00
#include <vector>
using namespace std;
2022-11-30 10:20:36 +00:00
typedef struct S0005ResultStruct {
int left1; // 边界情况为长度为 1 的字符时,扩展完成后的左边界
int right1; // 边界情况为长度为 1 的字符时,扩展完成后的右边界
int left2; // 边界情况为长度为 2 的字符串时,扩展完成后的左边界
int right2; // 边界情况为长度为 2 的字符串时,扩展完成后的右边界
} S0005Result;
class S0005 {
2022-11-02 09:32:58 +00:00
public:
/**
* @brief Longest Palindromic Substring
*
* Given a string s, return the longest palindromic substring in s.
*
* @param s the given string
* @return longest palindromic substring
*/
2022-11-30 10:20:36 +00:00
string longestPalindrome1(string s);
2022-11-02 09:32:58 +00:00
/**
* @brief Longest Palindromic Substring
*
* Given a string s, return the longest palindromic substring in s.
*
* @param s the given string
* @return longest palindromic substring
*/
2022-11-30 10:20:36 +00:00
string longestPalindrome2(string s);
S0005Result expand(string s, int i);
2022-11-02 09:32:58 +00:00
};
#endif