【Leetcode_easy】771. Jewels and Stones
problem
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的更多相关文章
- 【Leetcode】771. Jewels and Stones
(找了leetcode上最简单的一个题来找一下存在感) You're given strings J representing the types of stones that are jewels, ...
- 【LeetCode】771. Jewels and Stones 解题报告
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述: 题目大意 解题方法 数组count 字典Counter 日期 题目地址 ...
- Leetcode#771.Jewels and Stones(宝石与石头)
题目描述 给定字符串J 代表石头中宝石的类型,和字符串 S代表你拥有的石头. S 中每个字符代表了一种你拥有的石头的类型,你想知道你拥有的石头中有多少是宝石. J 中的字母不重复,J 和 S中的所有字 ...
- 771. Jewels and Stones - LeetCode
Question 771. Jewels and Stones Solution 题目大意:两个字符串J和S,其中J中每个字符不同,求S中包含有J中字符的个数,重复的也算 思路:Set记录字符串J中的 ...
- LeetCode --> 771. Jewels and Stones
Jewels and Stones You're given strings J representing the types of stones that are jewels, and S rep ...
- 【Leetcode_easy】1033. Moving Stones Until Consecutive
problem 1033. Moving Stones Until Consecutive 参考 1. Leetcode_easy_1033. Moving Stones Until Consecut ...
- 771. Jewels and Stones
You're given strings J representing the types of stones that are jewels, and S representing the ston ...
- LeetCode 771 Jewels and Stones 解题报告
题目要求 You're given strings J representing the types of stones that are jewels, and S representing the ...
- [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 ...
随机推荐
- vue 仿新闻项目笔记
1.main.js: import filters from 'XXX' Object.keys(filters).forEach(key => Vue.filter(key, filters[ ...
- mongoose 5.0 链接数据库 代码保存
const mongoose = require('mongoose'); const dbSrc = 'mongodb://localhost/douban-trailer' mongoose.Pr ...
- PowerDesigner创建表 拷贝创建表语句 SQLSERVER创建数据库 使用查询 创建表 并且添加数据
PowerDesigner创建表 : 1.双击打开PowerDesigner 2.双击打开Create model 3左键点击Model types,再点击Physical Data m ...
- 使用webuploader实现分片上传
这里只写后端的代码,基本的思想就是,前端将文件分片,然后每次访问上传接口的时候,向后端传入参数:当前为第几块文件,和分片总数 下面直接贴代码吧,一些难懂的我大部分都加上注释了: 上传文件实体类: 看得 ...
- leetcode解题报告(14):Max Consecutive Ones
描述 Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: ...
- ZOJ2314 Reactor Cooling(无源汇上下界可行流)
The terrorist group leaded by a well known international terrorist Ben Bladen is buliding a nuclear ...
- 点击按钮切换内容效果(使用CSS DIV与JavaScript)
<head><script type="text/javascript">function change_div(id){ if (id == 'gsyw ...
- Web前端-JavaScript基础教程下
Web前端-JavaScript基础教程下 <script>有6个属性: async对外部脚本有效,可以用来异步操作,下载东西,不妨碍其他操作. charset为src属性指定字符集. d ...
- PowerShell中汉字与ASCII码相互转换
function asc($param) { $rtn = '' $list = $param -split '' foreach ($char in $list) { if($char -ne '' ...
- 1820:【00NOIP提高组】进制转换
#include<bits/stdc++.h>//十分简单(滑稽)的一道模拟题 using namespace std; ]={'A','B','C','D','E','F','G','H ...