首页 > 小红的字符串
头像 丨阿伟丨
发表于 2025-08-28 09:46:14
题目链接 小红的字符串 题目描述 小红有一个长度为 的小写字母字符串 。她可以对字符串进行任意次操作:选择一个下标 ,将字符 循环右移到字母表中的下一个字母(例如 'a' 变成 'b','z' 变成 'a')。 请计算,使字符串 变为回文串所需的最少操作次数。 解题思路 本题的目标是,用最少的 展开全文
头像 牛客386945068号
发表于 2025-08-19 16:29:57
import java.util.*; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new S 展开全文
头像 小小虫44167
发表于 2025-10-08 16:37:57
s=input()l, r = 0,len(s)-1count=0while l<r:    diff = abs(ord(s[l])-ord(s[r]))    count += min(diff,26-diff)    l+=1    r-=1print(count)
头像 zhenghahahawda
发表于 2025-08-03 14:59:10
#include <iostream> using namespace std; int main() { string s;cin>>s; int l=0,r=s.size()-1; int c=0; while(l<r) { 展开全文
头像 papybara
发表于 2025-08-20 11:08:50
s = input().strip() res,a,b =0,0,len(s)-1 # 双指针,共同向中间逼近 while b>a: delta = abs(ord(s[a])-ord(s[b])) res += min(delta,26-delta) # 取(a增加到b,a 展开全文
头像 凌志文
发表于 2025-06-24 20:25:31
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = 展开全文
头像 ill__
发表于 2025-10-07 19:21:58
s = input() cnt = 0 n = len(s) for i in range(n//2):     d = abs(ord(s[i])& 展开全文
头像 AchanLin
发表于 2025-12-26 11:17:16
using System; using System.Collections.Generic; public class Program { public static void Main() { string str = Console.ReadLine(); 展开全文
头像 牛客226545250号
发表于 2025-08-25 15:44:12
#include <iostream> #include <string> #include <cmath> using namespace std; int main(){ string s; int count = 0; if(cin 展开全文
头像 niepan_gao
发表于 2025-06-25 08:51:59
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = 展开全文

等你来战

查看全部