int numJewelsInStones(string J, string S) {
set<char> st;
int count = ;
for (auto c : J)
{
st.insert(c);
}
for (auto s : S)
{
if (st.find(s) != st.end())
{
count++;
}
}
return count;
}

leetcode771的更多相关文章

  1. [Swift]LeetCode771. 宝石与石头 | Jewels and Stones

    You're given strings J representing the types of stones that are jewels, and S representing the ston ...

  2. Leetcode771.Jewels and Stones宝石与石头

    给定字符串J 代表石头中宝石的类型,和字符串 S代表你拥有的石头. S 中每个字符代表了一种你拥有的石头的类型,你想知道你拥有的石头中有多少是宝石. J 中的字母不重复,J 和 S中的所有字符都是字母 ...

  3. LeetCode-宝石与石头

    宝石与石头 LeetCode-771 使用哈希表. 这里使用内置算法库中的map /** * 给定字符串J 代表石头中宝石的类型,和字符串 S代表你拥有的石头.  * S 中每个字符代表了一种你拥有的 ...

随机推荐

  1. nginx 开启高效文件传输模式

    (1) sendfile 参数用于开启文件的高效传输模式,该参数实际上是激活了 sendfile() 功能,sendfile() 是作用于两个文件描述符之间的数据拷贝函数,这个拷贝操作是在内核之中的, ...

  2. php中wampserver多站点配置

    1.修改默认端口 : 2.添加多站点: 3.在文件的结尾添加一个站点配置: <VirtualHost *:8080> ServerAdmin webmaster@duoduo.com Do ...

  3. 分页控件 AspNetPager的使用

    1.引用AspNetPager.dll插件 1.下载AspNetPager.dll插件到bin文件夹中. 2.在“引用中添加引用”(不然报错:未能在全局命名空间中找到类型或命名名空间名称“Wuqi”) ...

  4. L2-007. 家庭房产(并查集)*

    L2-007. 家庭房产 参考博客 #include <iostream> #include <cstdio> #include <cstring> #includ ...

  5. python 写的员工信息查询

    #!/use/bin/env pythonn#_*_ coding:utf-8 _*_import timedef Bre():    while True:        Bre_falg = ra ...

  6. java基础(5)内部类

    1 成员内部类的定义和使用 public class Outer { private String name; public class Inner { public void innerMethod ...

  7. 学习笔记TF046:TensoFlow开发环境,Mac、Ubuntu/Linux、Windows,CPU版本、GPU版本

    下载TensorFlow https://github.com/tensorflow/tensorflow/tree/v1.1.0 .Tags选择版本,下载解压. pip安装.pip,Python包管 ...

  8. Google - chanceToLose24Game

    /* 一个类似24点的游戏,假设牌桌上有无数张1-10的牌,然后你手上的牌的总和是k,现在你可以随机到牌桌上抽牌加到总和里,如果你手上牌的总和在20-25之间就是win,如果总和超过25就是lose, ...

  9. Python2和Python3关于reload()用法的区别

    Python2 中可以直接使用reload(module)重载模块. Pyhton3中需要使用如下两种方式: 方式(1) >>> from imp >>> imp. ...

  10. SSM框架的配置

    主要是这三个配置文件 web.xml(用来加载和初始化下面的配置文件) applicationcontet.xml(就是Spring的配置文件,一般包括声明式失误等等AOP) Sprimgmvc,xm ...