• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 






乘风有时

 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理

随笔分类 -  回文

 
[LeetCode]Palindrome Pairs
摘要:题目:Palindrome Pairs Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two wo 阅读全文
posted @ 2017-08-10 22:51 乘风有时 阅读(187) 评论(0) 推荐(0)
[LeetCode]Shortest Palindrome
摘要:题目:Shortest Palindrome 给定字符串,在前面增加最少字符使其组成回文字符串。 思想: 只要找到从字符串头部开始的最长回文子串,就能将剩下的字符串逆置后拼接到前面而得到最短的回文字符串。 /**判断字符串是回文的**/ bool isPalindrome(string s){ if 阅读全文
posted @ 2017-05-02 17:43 乘风有时 阅读(157) 评论(0) 推荐(0)
[LeetCode]Palindrome
摘要:题目:Palindrome Number 确定一个整数是否是回文。要求没有额外的空间。 思路: 如果有首尾两个指针,则一次比较两个指针对应的数字的值,就能够知道是不是回文数字了; 但是,怎么从后往前遍历呢? 我们可以定义一个数组,分别记录个、十、百、千、万...的位数然后除以数组对应的位数就能从后往 阅读全文
posted @ 2017-04-16 22:31 乘风有时 阅读(311) 评论(0) 推荐(0)
[LeetCode]Longest Palindromic Substring
摘要:题目:Longest Palindromic Substring 查找最长回文子串 思路: 一个指针从头部,一个指针从尾部,对比每一个字母,若相等则可能是回文子串,则,检测子串是否回文,是则比较和已知的子串长度,更长就记录其起始和终止坐标,否则就放弃。 上面的思路是从两边向中间收束,另一个思路是从中 阅读全文
posted @ 2017-04-04 22:53 乘风有时 阅读(246) 评论(0) 推荐(0)