problem

771. Jewels and Stones

solution1:

class Solution {
public:
int numJewelsInStones(string J, string S) {
int res = ;
unordered_set<char> js(J.begin(), J.end());
for(auto ch:S)
{
if(js.find(ch)!=js.end()) res++;
}
return res;
}
};

参考

1. Leetcode_easy_771. Jewels and Stones;

2. Grandyang;

【Leetcode_easy】771. Jewels and Stones的更多相关文章

  1. 【Leetcode】771. Jewels and Stones

    (找了leetcode上最简单的一个题来找一下存在感) You're given strings J representing the types of stones that are jewels, ...

  2. 【LeetCode】771. Jewels and Stones 解题报告

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述: 题目大意 解题方法 数组count 字典Counter 日期 题目地址 ...

  3. Leetcode#771.Jewels and Stones(宝石与石头)

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

  4. 771. Jewels and Stones - LeetCode

    Question 771. Jewels and Stones Solution 题目大意:两个字符串J和S,其中J中每个字符不同,求S中包含有J中字符的个数,重复的也算 思路:Set记录字符串J中的 ...

  5. LeetCode --> 771. Jewels and Stones

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

  6. 【Leetcode_easy】1033. Moving Stones Until Consecutive

    problem 1033. Moving Stones Until Consecutive 参考 1. Leetcode_easy_1033. Moving Stones Until Consecut ...

  7. 771. Jewels and Stones

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

  8. LeetCode 771 Jewels and Stones 解题报告

    题目要求 You're given strings J representing the types of stones that are jewels, and S representing the ...

  9. [LeetCode&Python] Problem 771: Jewels and Stones

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

随机推荐

  1. Java多线程下载初试

    一.服务端/客户端代码的实现 服务端配置config @ConfigurationProperties("storage") public class StoragePropert ...

  2. native关键字

    1.native关键字说明其修饰的方法是一个原生态方法,方法对应的实现不是在当前文件,而是在用其他语言(如C和C++)实现的文件中. 可以将native方法比作Java程序同C程序的接口

  3. Codeforces Round #600 (Div. 2) D题【并查集+思维】

    题意:给你n个点,m条边,然后让你使得这个这个图成为一个协和图,需要加几条边.协和图就是,如果两个点之间有一条边,那么左端点与这之间任意一个点之间都要有条边. 思路:通过并查集不断维护连通量的最大编号 ...

  4. pstmt.getGeneratedKeys()更换jar包后报错

    改成: pstmt=conn.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS); rs=pstmt.getGeneratedKeys(); 即 ...

  5. QT中使用pri子工程

    QT中使用pri子工程 使用子工程的作用是使得工程结构更加清晰,举个例子: 我制作了一个自定义控件,具备通用性,我打算把它用在日后的工程中.制作的这个控件需要用到头文件h.源文件c,资源文件qrc.图 ...

  6. jQuery相关方法9----事件相关

    一.事件冒泡和阻止事件冒泡 <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></s ...

  7. NetworkX系列教程(10)-算法之一:最短路径问题

    小书匠Graph图论 重头戏部分来了,写到这里我感觉得仔细认真点了,可能在NetworkX中,实现某些算法就一句话的事,但是这个算法是做什么的,用在什么地方,原理是怎么样的,不清除,所以,我决定先把图 ...

  8. Linux 下Mongdb数据库

    一.安装mongdb 1.创建安装目录 # mkdir /data/local # mkdir /data/local/mongodbdata 2.解压安装包 # tar -xvf /software ...

  9. 数据结构实验之查找一:二叉排序树 (SDUT 3373)

    二叉排序树(Binary Sort Tree),又称二叉查找树(Binary Search Tree),也称二叉搜索树. #include <stdio.h> #include <s ...

  10. 【原创】sed正则表达式替换

    1.数字替换原数字 sed -i "s/\([0-9]*\)/\1/g"