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. java中的线程问题(三)——继承Thread VS 实现Runnable的区别

    从java的设计来看,通过继承Thread或者实现Runnable接口来创建线程本质上没有区别,从jdk帮助文档我们可以看到Thread类本身就实现了Runnable接口,如果一定要说它们有什么区别, ...

  2. Java语法基础学习DayFourteen(IO)

    一.java.io.FIle类 1.特点 (1)凡是与输入.输出相关的类.接口等都定义在java.io包下. (2)File是一个类,使用构造器创建对象,此对象对应一个文件(.txt .avi .do ...

  3. quora 的东西就是不一样

    Coding is just a part of process of problem solving, You should need to understand the underlying pr ...

  4. Linux运维之shell脚本进阶篇

    一.if语句的使用 1)语法规则 if [条件] then 指令 fi 或 if [条件];then 指令 fi 提示:分号相当于命令换行,上面两种语法等同特殊写法:if[ -f"$file ...

  5. python day27--网络编程

    一‘.网络基础 1.什么是IP IP地址是指互联网协议地址(英语:Internet Protocol Address,又译为网际协议地址),是IP Address的缩写.IP地址是IP协议提供的一种统 ...

  6. 2.oracle之用户管理sql

    --创建用户--create user  用户名  identified by  密码;create user jojo identified by bean; --给用户授权--grant conn ...

  7. nf_conntrack

    How to Fix Nf_conntrack Table Full Dropping Packet Linux CentOS PacketLoss  2 minutes to read (234 w ...

  8. 获取真实ip三个方法

    方法一: /** * 获取客户端IP地址 * * @return string */function get_client_ip(){ if (getenv("HTTP_CLIENT_IP& ...

  9. 《ProgrammingHive》阅读笔记-第二章

    书本第二章的一些知识点,在cloudera-quickstart-vm-5.8.0-0上进行操作. 配置文件 配置在/etc/hive/conf/hive-site.xml文件里面,采用mysql作为 ...

  10. LADP(Lightweight Directory Access Protocol)轻量目录访问协议~小知识

    What is LDAP and how does it work(implementation)? LDAP stands for “Lightweight Directory Access Pro ...