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. vue router.beforeEach(),详解

    outer.beforeEach()一般用来做一些进入页面的限制. 比如没有登录, 就不能进入某些页面,只有登录了之后才有权限查看某些页面...说白了就是路由拦截.第一步 规定进入路由需不需要权限 @ ...

  2. JavaScript-日常代码-时间

    取得今天0点: var start = new Date(new Date(new Date().toLocaleDateString()).getTime()); console.log(start ...

  3. How To Add User To Sudoers On Debian 10 Buster

    In today’s tutorial, we are going to see how you can add a user to sudoers on Debian distributions. ...

  4. WCF wsHttpBinding in SoapUI

    当使用wsHttpBinding,而不是平时用的webHttpBinding的时候,用soapui会报错.这个时候需要选中WS-A选项中的"Add default wsa:Action&qu ...

  5. Cogs 731. [网络流24题] 最长递增子序列(最大流)

    [网络流24题] 最长递增子序列 ★★★☆ 输入文件:alis.in 输出文件:alis.out 简单对比 时间限制:1 s 内存限制:128 MB «问题描述: 给定正整数序列x1,-, xn. ( ...

  6. Bzoj 1566: [NOI2009]管道取珠(DP)

    1566: [NOI2009]管道取珠 Time Limit: 20 Sec Memory Limit: 650 MB Submit: 1558 Solved: 890 [Submit][Status ...

  7. SpringMVC 捕获参数绑定失败时的异常

    SpringMVC配置数据验证(JSR-303)中提到了用String类型的域来绑定Ajax中的非法类型的参数. 这样做的目的是一旦发生一种情况,后端可以返回一个自定类的返回值,而不是返回Spring ...

  8. java生成临时文件夹和删除临时文件夹

    为了不生成同名的文件夹 String s = UUID.randomUUID().toString(); String filepath = ServletActionContext.getServl ...

  9. 安装virtual box

    将安装包放在app目录下: 进入安装目录,输入sudo gdebi 安装包名 安装完后,可以在搜索框中搜索:virtual 会出现安装好的虚拟机盒子.

  10. JS中的常用的代码操作

    本文件介绍常用的js代码的DOM操作.CSS操作.对象(Object对象.Array对象.Number对象.String对象.Math对象.JSON对象和Console对象)操作说明. 一.DOM树的 ...