ICode9

精准搜索请尝试: 精确搜索
  • papamelong 308. 最廉价的回文串 Cheapest Palindrome2022-09-04 21:33:59

    https://www.papamelon.com/problem/308 给定一个长度为 m(m≤2000) 的小写字母字符串, 在给定组成该字符串的 n(n≤26) 个字符的添加和删除费用, 求使原字符串变为回文串的最小费用。 输入 第一行包含两个整数 n 和 m 第二行为长度为 m 的字符串, 接下来有 n 行, 每行首先是一个

  • leetcode 409 Longest Palindrome 最长回文串(简单)2022-08-31 13:30:49

    一、题目大意 给定一个包含大写字母和小写字母的字符串 s ,返回 通过这些字母构造成的 最长的回文串 。 在构造过程中,请注意 区分大小写 。比如 "Aa" 不能当做一个回文字符串。 示例 1: 输入:s = "abccccdd" 输出:7 解释: 我们可以构造的最长的回文串是"dccaccd", 它的长度是 7。

  • LeetCode 131 Palindrome Partitioning2022-08-16 03:30:08

    Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. A palindrome string is a string that reads the same backward as forward. Solution 将字符串分割为所有可能的回文串。 首先

  • AtCoder Regular Contest 1452022-08-08 04:00:53

    题目传送门:AtCoder Regular Contest 145。 目录A - AB Palindrome A - AB Palindrome 题意简述

  • P1435 [IOI2000] 回文字串 / [蓝桥杯 2016 省] 密码脱落2022-07-27 08:32:28

    https://www.luogu.com.cn/problem/P1435动态规划,LCS黄色题 字符串输入下标从0开始!!!!!!!!!!!!!!!!!!!  #include<cstdio> #include<cstring> #include<iostream> #include<cstdlib> using namespace std; int n; int dp[5001][5001]; char str1[5001],str2[5001]

  • POJ3280 Cheapest Palindrome (区间DP)2022-06-17 20:03:45

    dp[i][j]表示将字符串子区间[i,j]转化为回文字符串的最小成本。 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #include<cmath> 5 #include<string> 6 #include<iostream> 7 using namespace std; 8 const int maxn=2010; 9 int n

  • LeetCode 131. Palindrome Partitioning2022-06-14 15:05:48

    LeetCode 131. Palindrome Partitioning (分割回文串) 题目 链接 https://leetcode.cn/problems/palindrome-partitioning/ 问题描述 给你一个字符串 s,请你将 s 分割成一些子串,使每个子串都是 回文串 。返回 s 所有可能的分割方案。 回文串 是正着读和反着读都一样的字符串。 示例

  • string match 字符串匹配2022-06-13 03:00:43

    214. Shortest Palindrome Hard You are given a string s. You can convert s to a palindrome by adding characters in front of it. Return the shortest palindrome you can find by performing this transformation.  Example 1: Input: s = "aacecaaa" O

  • python 练习题 409. 最长回文串2022-06-01 20:31:08

    地址:https://leetcode.cn/problems/longest-palindrome/   1 ''' 2 给定一个包含大写字母和小写字母的字符串 s ,返回 通过这些字母构造成的 最长的回文串 。 3 4 在构造过程中,请注意 区分大小写 。比如 "Aa" 不能当做一个回文字符串。 5 6   7 8 示例 1: 9

  • 2022湖北省赛 J. Palindrome Reversion (字符串哈希)2022-06-01 20:02:53

    https://codeforces.com/gym/103729/problem/J 题意: 选择一个子串翻转一次,问是否能得到一个回文串 #include<bits/stdc++.h> //#include <bits/extc++.h> using namespace std; // using namespace __gnu_cxx; // using namespace __gnu_pbds; #define IOS ios::sync_with_stdio(

  • LeetCode 0132 Palindrome Partitioning II2022-05-20 07:31:18

    原题传送门 1. 题目描述 2. Solution 1 1、思路分析 1> 状态定义: dp[i] 表示以s[0, i]的最少分割次数。 2> 边界: dp[i] = i。至少,单个字符就是回文的。 3> 状态转移方程: 遍历s,设工作变量为mid,表示回文的中心位置。 case 1: s长度是奇数,中心位置在mid下标处,延伸至两端。 case 2

  • LeetCode 0131 Palindrome Partitioning2022-05-19 08:34:24

    原题传送门 1. 题目描述 2. Solution 1 1、思路分析 回溯法。 2、代码实现 package Q0199.Q0131PalindromePartitioning; import java.util.ArrayList; import java.util.List; /* Backtracking */ public class Solution { public List<List<String>> partition(Str

  • LeetCode 0132 Palindrome Partitioning II2022-05-19 08:31:07

    原题传送门 1. 题目描述 2. Solution 1 1、思路分析 1> 状态定义: dp[i] 表示以s[0, i]的最少分割次数。 2> 边界: dp[i] = i。至少,单个字符就是回文的。 3> 状态转移方程: 遍历s,设工作变量为mid,表示回文的中心位置。 case 1: s长度是奇数,中心位置在mid下标处,延伸至两端。 case 2

  • leetcode 680. Valid Palindrome II 验证回文字符串 Ⅱ2022-05-18 13:03:52

    一、题目大意 https://leetcode.cn/problems/valid-palindrome-ii/ 给定一个非空字符串 s,最多删除一个字符。判断是否能成为回文字符串。 示例 1: 输入: s = "aba" 输出: true 示例 2: 输入: s = "abca" 输出: true 解释: 你可以删除c字符。 示例 3: 输入: s = "abc" 输出

  • leetcode-0234 Palindrome Linked List2022-05-16 22:04:53

    Given the head of a singly linked list, return true if it is a palindrome. Example 1: Input: head = [1,2,2,1] Output: true Example 2: Input: head = [1,2] Output: false Constraints: The number of nodes in the list is in the range [1, 105]. 0 <= Node.va

  • 125. Valid Palindrome2022-04-09 05:00:06

    class Solution { public boolean isPalindrome(String s) { s= s.toLowerCase(); int i=0, j=s.length()-1; while(i<j){ char a = s.charAt(i); char b = s.charAt(j); if(!(Character.isLetter(a)||Ch

  • 9.14.10-PointersOnC-202203022022-03-02 12:33:40

    #include<stdio.h> #include<string.h> #include<ctype.h> int is_palindrome(char *string); int main(int argc,char *argv[]){ char str[]="Madam,I'm Adam"; fputs(is_palindrome(str)?"It's a palindrome.\n":"

  • 5. 最长回文子串(Java) Leecode2022-03-01 20:06:47

    先复习下简单的回文数。 利用反转数字。 回文数 解题思路: 不同之处在于,对于回文子串,反转的方式会出现错误。 方法:中心扩散法 +双指针 class Solution { public String longestPalindrome(String s) { String res = ""; for(int i = 0; i < s.length();

  • LeetCode 0009 Palindrome Number2022-02-27 08:00:55

    原题传送门 1. 题目描述 2. Solution 1 1、思路分析 反转一半数字,对比是否相等。 2、代码实现 package Q0099.Q009PalindromeNumber; /* 手动模拟Stack */ public class Solution { public boolean isPalindrome(int x) { if (x < 0 || (x % 10 == 0 && x != 0)

  • 1136 A Delayed Palindrome (20 分) (高精度 回文数)2022-02-22 19:58:40

    添加链接描述 高精度加法判断回文数 #include<bits/stdc++.h> using namespace std; bool check(string s){ string p=s; reverse(p.begin(),p.end()); return p==s; } string add_(string a,string b){ string c; int p=0; for(int i=0;i<max((int)

  • 【LeetCode】判斷是否為回文Palindrome2022-01-27 12:35:40

    這次的題目是剛開始學習程式語言的初學者都學過的邏輯: 回文 一樣先來看下題目 Given an integer x, return true if x is palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, 121 is a palindrome while 123 is not

  • LeetCode - 解题笔记 - 132 - Palindrome Partitioning II2022-01-22 14:03:01

    Solution 1 实际上就是承接了 0131. Palindrome Partitioning 的设计思路,使用动态规划 进行处理。 【参考官方】整个过程有两个优化要求: 划分的枚举最优化:动态规划()回文判定的最优化:动态规划(0005. Longest Palindromic Substring 或 0131. Palindrome Partitioning ) 第二个

  • [LeetCode] 1278. Palindrome Partitioning III 拆分回文串之三2022-01-03 11:32:38

    You are given a string s containing lowercase letters and an integer k. You need to : First, change some characters of s to other lowercase English letters. Then divide s into k non-empty disjoint substrings such that each substring is a palindrome

  • 680. Valid Palindrome II2022-01-03 05:31:06

    这道题的暴力解法很简单,先check如果不删除任何字符,是否字符串是回文,如果不是,再挨个删除每个字符,check删除字符之后是否是回文。 时间复杂度O(n2), n是字符串s的长度,字符串很长的情况下会TLE,算法如下: class Solution { public boolean validPalindrome(String s) { if

  • CF1140E Palindrome-less Arrays2021-12-30 19:36:32

    题面传送门 首先这个回文串很玄学,我们考虑如果一个回文串的长度大于\(3\),那么以它为中心的长度为\(3\)的回文串一定更符合要求。 所以我们的要求转化为每个点左右两边要不一样。 如果我们将奇偶分开,那么就是要每个都相邻不同,这个随便dp就好了。 code: #include<bits/stdc++.h> #de

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

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

ICode9版权所有