ICode9

精准搜索请尝试: 精确搜索
  • [Leetcode]5.Longest Palindromic Substring2019-09-23 23:05:11

    这段时间重新刷了一下Leetcode,在此记录下自己容易出错的和经典的题目。 这是Leetcode第5题,寻找最长回文子序列,就是给定一个字符串S,找出其中的最长回文子串,并返回该子串。常用的方法有中心扩展法与Manacher算法,其中Manacher算法时间复杂度可以达到\(O(N)\), 空间复杂度\(O(N)\),需要

  • 5. 最长回文子串_Longest Palindromic Substring2019-09-06 19:42:00

    Longest Palindromic Substring Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. 给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 题目来源:力扣(LeetCode)链接:https://

  • PAT A1024 Palindromic Number (25 分) 大数加法2019-08-26 10:42:16

        题目大意:判断一个不超过10^10的数N,能否在K步内通过加上自身的反转数变成回文数。     与A1023 Have fun with Numbers 相同,依然是大数加法,用vector<int>存储并按照要求反转相加,判断回文即可。     坑点在于开始的输入时,N 要设置成long long型,设置成 int 型会溢出导

  • 5. Longest Palindromic Substring2019-08-25 13:37:57

    Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: “babad” Output: “bab” Note: “aba” is also a valid answer. Example 2: Input: “cbbd” Output: “bb” 问题: 寻找字

  • PAT A1019 General Palindromic Number2019-08-23 22:51:03

    PAT A1019 General Palindromic Number 题目描述:   A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers.  Alth

  • Codeforces 1205C Palindromic Paths (交互题、DP)2019-08-21 16:02:40

    题目链接 http://codeforces.com/contest/1205/problem/C 题解 菜鸡永远做着变巨的梦 然而依然连div1BC题都不会做 要是那天去打cf怕是又要1题滚粗了。。。。 首先第一步显然是对于所有\(i+j\)为偶数的点(下称“偶点”)求出\(a_{i,j}\)的值,对于所有\(i+j\)为奇数的点(下称“奇点

  • 题解 P3126 【[USACO15OPEN]回文的路径Palindromic Paths】2019-07-16 15:04:01

    P3126 [USACO15OPEN]回文的路径Palindromic Paths 看到这题题解不多,蒟蒻便想更加通俗易懂地分享一点自己的心得,欢迎大佬批评指正^_^ 像这种棋盘形的两边同时做的dp还有 P1006 传纸条, P1004 方格取数, T35377 大教室中传纸条 一、思路改进 对于这种题目最暴力的方法无非是分别枚

  • PAT A1019 2019.07.142019-07-14 15:05:23

    1019 General Palindromic Number (20 分) A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers. Although p

  • Longest Palindromic Substring(最长回文子串)2019-06-23 19:53:46

    题目描述: Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.   这是一道很有名的题目,相信很多人面试的时候会被问到。   本人算法能力

  • 5. Longest Palindromic Substring[M]2019-06-09 08:55:33

    题目 Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example1:   Input: "babad"   Output: "bab"   Note: "aba is also a valid answer. " Example2:   Input: "

  • LeetCode 1005 Longest Palindromic Substring2019-05-31 13:44:06

    题目 c++ 回文串,区间DP class Solution { public: int dp[1005][1005]; string longestPalindrome(string s) { int len = s.length(); int ii,jj; int m=0; for(int l=0;l<len;l++) {

  • PAT_A1136#A Delayed Palindrome2019-05-24 21:38:19

    Source: PAT_A1136 A Delayed Palindrome (20 分) Description: Consider a positive integer N written in standard notation with k+1 digits a​i​​ as a​k​​⋯a​1​​a​0​​ with 0 for all i and a​k​​>0. Then N is palindromic if and o

  • 5. Longest Palindromic Substring2019-05-04 19:48:01

    Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: "bab" Note: "aba" is also a valid answer. Example 2: Input: "cbbd"

  • LOJ2484 CEOI2017 Palindromic Partitions DP、回文树2019-05-03 11:43:01

    传送门 当我打开Luogu题解发现这道题可以Hash+贪心的时候我的内心是崩溃的…… 但是看到这道题不都应该认为这是一道PAM的练手好题么…… 首先把原字符串重排为\(s_1s_ks_2s_{k-1}s_3s_{k-2}...\)之后,我们不难发现:在一种对原串的回文划分中,对应的一对字符串在新的字符串上对应了一

  • 【Leetcode】No.5 Longest Palindromic Substring2019-04-22 13:50:15

    一、暴力法 public String longestPalindrome(String s) { //暴力算法 if(s.isEmpty()){ return s; } String res = s.substring(0,1); for (int i =0; i<s.length();i++){ for (int j=i+1;j<=s.length();j

  • PAT A10242019-04-19 12:49:52

    题目: A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers. Non-palindromic numbers can be paired with pal

  • 1024 Palindromic Number [模拟]2019-03-24 18:44:27

    这题写的比较匆忙,代码有点乱,仅供参考。有个坑就是一开始给的数字就是回文串,要先判断,注意一下。 #include <iostream>#include <string.h>#include <cstdio>#include <algorithm>#include <cstdlib>#include <math.h>#include <queue>#include <stack>#include <v

  • Leetcode 5. 最长回文子串(Longest Palindromic Substring)2019-03-13 21:51:46

    方法一: class Solution { public: string longestPalindrome(string s) { if (s.size() < 2) return s; int n = s.size(), maxLen = 0, start = 0; for (int i = 0; i < n - 1; ++i) { searchPalindrome(s, i, i

  • 5. Longest Palindromic Substring2019-03-10 11:03:34

    题目:最长的回文串 Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad"Output: "bab"Note: "aba" is also a valid answer. Example 2: Input: "c

  • PAT A1136 A Delayed Palindrome (20 分)2019-02-23 21:42:43

    Consider a positive integer N written in standard notation with k+1 digits a​i​​ as a​k​​⋯a​1​​a​0​​ with 0≤a​i​​<10 for all i and a​k​​>0. Then N is palindromic if and only if a​i​​=a​k−i​​ for all i. Zero is w

  • PAT A1019 General Palindromic Number (20 分)2019-02-17 15:50:05

    A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers. Although palindromic numbers are most often considere

  • 5. Longest Palindromic Substring2019-02-13 23:38:07

    5. Longest Palindromic Substring Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: "bab" Note: "aba" is also a valid answer.

  • 洛谷 P4656: LOJ 2484: [CEOI2017]Palindromic Partitions2019-02-08 23:00:42

    菜菜只能靠写简单字符串哈希维持生活。 题目传送门:LOJ #2484。 题意简述: 题面讲得很清楚了。 题解: 很显然从两边往中间推,能选的就选上这个贪心策略是对的。 如何判断能不能选上,直接字符串哈希吧。 有一个小细节:中间那块要不要选,即ans要不要加1?判一下串长即可。 #include <cstdio> #

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有