[hackerrank]The Love-Letter Mystery
https://www.hackerrank.com/contests/w3/challenges/the-love-letter-mystery
简单题。
#include <cstdlib>
#include <string>
#include <iostream> using namespace std; int main() {
int N;
cin >> N;
while (N--) {
string s;
cin >> s;
int count = 0;
int l = 0;
int r = s.size() - 1;
while (l < r) {
count += abs(s[l++] - s[r--]);
}
cout << count << endl;
}
return 0;
}
[hackerrank]The Love-Letter Mystery的更多相关文章
- 【HackerRank】The Love-Letter Mystery
James找到了他的朋友Harry要给女朋友的情书.James很爱恶作剧,所以他决定要胡搞一下.他把信中的每个单字都变成了回文.对任何给定的字符串,他可以减少其中任何一个字符的值,例如'd'可以变成' ...
- [LeetCode] Letter Combinations of a Phone Number 电话号码的字母组合
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- 17. Letter Combinations of a Phone Number
题目: Given a digit string, return all possible letter combinations that the number could represent. A ...
- 什么是Unicode letter
起因:从一段代码说起 using System; using System.Collections.Generic; using System.Linq; using System.Text; usi ...
- LeetCode——Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- 日常小测:颜色 && Hackerrank Unique_colors
题目传送门:https://www.hackerrank.com/challenges/unique-colors 感谢hzq大神找来的这道题. 考虑点分治(毕竟是路经统计),对于每一个颜色,它的贡献 ...
- No.017:Letter Combinations of a Phone Number
问题: Given a digit string, return all possible letter combinations that the number could represent.A ...
- SCI/EI期刊投稿 Reply Letter 常用格式总结
SCI/EI期刊投稿Reply Letter常用格式总结 整个论文投稿的过程中,会遇到各种问题,需要我们向主编询问或是回复.下面主要总结了responses to the comme ...
- 【leetcode】 Letter Combinations of a Phone Number(middle)
Given a digit string, return all possible letter combinations that the number could represent. A map ...
随机推荐
- 支持IE6的树形节结构TreeTable
关于TreeTable实际应用的案例:http://www.cnblogs.com/qigege/p/5213689.html treeTable是跨浏览器.性能很高的jquery的树表组件,它使用非 ...
- 批处理bat命令--获取当前盘符和当前目录和上级目录
批处理bat命令--获取当前盘符和当前目录和上级目录 批处理命令获取当前盘符和当前目录%~d0 是当前盘符%cd% 是当前目录可以用echo %cd%进行打印测试 以下例子是命令行编译Visual S ...
- Oracle SQL 劈开字符串
一.数据样例 二.劈开单行 , rownum) h2 FROM (select id_,name_ from test_reg_count t ) CONNECT ; --或者 , rownum) h ...
- [转]MAC下JDK版本的切换
系统里之前先安装里jdk6的,后台又装里7,安装完成后,java -version 版本是7, 导致我eclipse打不开,一开始的做法是,把7的版本给删除掉. 删除的方法也很简单,在命令行中到 / ...
- MySQL 主键冲突,无法插入数据
数据库版本:5.6.16 问题:开发来电话说仓库无法下单,程序插入数据提示:入库单 xxxx1589762285确认失败:Duplicate entry '8388607' for key 'PRIM ...
- WPF-控件-层级控件-TreeView
<?xml version="1.0" encoding="utf-8" ?> <Data xmlns=""> &l ...
- java 常见异常(二)
java.lang.ClassCastException: com.bjsxt.HomeWrok.oop.polymorphism.UP cannot be cast to com.bjsxt.Hom ...
- springboot pom 引用集合
<dependency><groupId>com.google.code.gson</groupId><artifactId>gson</arti ...
- C/C++ 内联函数
内联函数具备一般函数的性质,但是不需要调用,而是在编译阶段,会用函数体替换函数名被调用的地方.可以节省调用时间(进出栈.保存上下文). 在编译层面和宏的作用相同.内联函数的展开在编译阶段,宏展开在预处 ...
- net windows Kafka
net windows Kafka 安装与使用入门(入门笔记) 完整解决方案请参考: Setting Up and Running Apache Kafka on Windows OS 在环境搭建 ...