HackerRank - camelcase 【字符串】
思路
找单词
第一个 单词 是小写
然后 后面的单词 第一位 都是大写
刚开始 初始化 ans = 1
然后 往后遍历
碰到 大写的 更新答案
AC代码
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <climits>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits>
using namespace std;
typedef long long LL;
const double PI = 3.14159265358979323846264338327;
const double E = 2.718281828459;
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;
int main()
{
string s;
cin >> s;
int len = s.size();
LL ans = 1;
for (int i = 0; i < len; i++)
{
if (s[i] >= 'A' && s[i] <= 'Z')
ans++;
}
cout << ans << endl;
}
HackerRank - camelcase 【字符串】的更多相关文章
- webstrom官方的活动模版介绍
编辑模板变量对话框 文件|设置|生活模板--编辑变量Windows和LinuxWebStorm |偏好|生活模板--编辑变量在OS XCtrl + Alt + S 当你点击对话框打开 编辑变量按钮模板 ...
- IntelliJ IDEA实时模板变量
返回由当前方法返回的值的类型IntelliJ IDEA 实时模板中的模板变量允许用户输入.扩展模板后,变量将作为输入字段显示在编辑器中. IntelliJ IDEA 声明实时模板变量 模板中的变量以下 ...
- webstorm的live templates快速编辑功能,让你的css JS代码书写速度飞起来
前言: Emmet的前身是大名鼎鼎的Zen coding,如果你从事Web前端开发的话,对该插件一定不会陌生.它使用仿CSS选择器的语法来生成代码, 大大提高了HTML/CSS代码编写的速度,比如下面 ...
- HackerRank - beautiful-binary-string 【字符串】
题意 给出一个 N 位的 01 串 然后 每次 改动 可以将其中的 (0 -> 1) 或者 (1 -> 0) 然后 求 最少几次 改动 使得 这个 01 串 当中 不存在 连续的 010 ...
- jQuery静态方法noop,camelCase,nodeName,trim使用和源码分析
noop方法 jQuery.noop()函数是一个空函数,它什么也不做. 当某些时候你需要传入函数参数,而且希望它什么也不做的时候,你可以使用该函数,也无需再新建一个空的函数. 示例: // 传入一个 ...
- jQuery 源码中的 camelCase
先看一下源码 //65-72行 // Matches dashed string for camelizing //匹配连字符 ‘-’ 和其后的第一个字母或数字,如果是字母,则替换为大写,如果是数字, ...
- JSONModel - 字符串换转实体类
JSONModel https://github.com/icanzilb/JSONModel/ 一. 获取属性的元数据 const char *attrs = property_getAttrib ...
- 【JavaScript】字符串处理函数集合
var $string = {}, toString, template, parseURL, buildURL, mapQuery, test, contains, trim, clean, cam ...
- *[hackerrank]Sam and sub-strings
https://www.hackerrank.com/contests/w3/challenges/sam-and-substrings DP.注意到以N[i]结尾的每个字符串的子数字和有规律: 53 ...
随机推荐
- LeetCode题目:Gray Code
原题地址:https://leetcode.com/problems/gray-code/ class Solution { public: vector<int> grayCode(in ...
- Web用户的身份验证及WebApi权限验证流程的设计和实现(续)
4.4 权限属性RequireAuthorizationAttribute [csharp] view plaincopy "font-size:14px;">/// / ...
- java swing内嵌浏览器,隐藏滚动条
1 通过定义css样式表来解决 1 html{overflow-y:scoll;overflow:-moz-scrollbars-vertical;} 2 body{width:680px;heigh ...
- 500 lines or less
今天碰到一本书 <500 lines or less>突然就想在博客上记录一下自己的阅读经历了. 现在记录一下这本书的地址 http://aosabook.org/en/index.htm ...
- llinux获取系统时间
linux中获取当前时间.统计程序运行时间,可以使用gettimeofday()得到毫秒级的时间统计,利用rdtsc指令获取纳秒级时间统计. gettimeofday() 它是一个linux C库函数 ...
- 小白学习HTTPS
如果你和我一样是HTTPS的小白的话,那就一起来学习这个吧.争取把这篇博客写好,写全面,从原理到实践再到部署. 让我们先来模拟一个场景:当你嗨皮地敲着代码,你的老板偷偷摸摸跑到你的身边,"小 ...
- Sphinx(Coreseek)安装和使用指南
1.安装 1.1安装mmseg ./bootstrap # 必须执行,不然安装会失败 ./configure --prefix=/usr/local/mmseg- #指定安装目录 make make ...
- window安装redis
1.redis简介redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合).zset(so ...
- 多媒体开发之---H264 RTSP交互过程
OPTIONS rtsp://192.168.1.154:8557/h264 RTSP/1.0 CSeq: 1 User-Agent: VLC media player (LIVE555 Stream ...
- 源码安装Apache,报错:Cannot use an external APR with the bundled APR-util
一般在第一次源码安装是没有问题的,在版本变化情况下在次源码安装可能会遇到此问题: apache2.0.x与apache2.2.x在apr有很大区别,前者为依赖公用apr,后者依赖于自身的apr.一般前 ...