【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 ...
随机推荐
- python多线程实现ping多个ip
#!/usr/bin/env python # -*- coding:utf-8 -*- import subprocess import logging import datetime import ...
- 2019牛客多校B Beauty Values——思维题
题目 求所有子区间中不同元素之和. 分析 枚举相邻的相同数字形成的区间,计算它是哪些区间的子区间,每次有-1的贡献,将其从总贡献中减去. #include<bits/stdc++.h> u ...
- 006——C#关闭窗口 添加FormClosing事件
(一)参考文献:C# 添加FormClosing事件 (二)在 项目名.Designer.cs中的InitializeComponent()添加: this.FormClosing += new S ...
- NCNN使用总结
目录 NCNN简介 NCNN注意事项 NCNN使用心得 小技巧 小想法 NCNN简介 ncnn 是一个为手机端极致优化的高性能神经网络前向计算框架.ncnn 从设计之初深刻考虑手机端的部署和使用.无第 ...
- 【原创】go语言之打印目录
package main import ( "fmt" "io/ioutil" "log" ) func listFiles(dirname ...
- Linux MySQL 储存中文失败简单解决办法
如图,保存的中文都变成了??? show create table table_name;可以查到表的默认编码 这里看到默认的字符集是latin1,而不是utf8 需要修改 alter databas ...
- Docker实战笔记
好记性不如烂笔头,持续高产~ 0x01 Docker创建nginx容器 1.流程 docker info 显示Docker系统信息,包括镜像和容器数 示例: 使用镜像 nginx:latest 以交互 ...
- vue的ui组件库
https://www.cnblogs.com/dupd/p/7735450.html
- python3删除mysql上月分区数据(脚本)
import datetime import pymysql import pymysql.cursors tables_schdule=["talbe1","table ...
- Vue进阶(Bus/作用域slot/动态组件)
一.Vue非父子组件传值(Bus/总线/发布订阅模式/观察者模式) 我们在之前已经知道了父子传值.父组件传递过来了的值,在子组件通过props接受,然后就可以使用了. 也学过了隔代传值,均是通过pro ...