You're given strings
J
representing the types of stones that are jewels, andS
representing the stones you have. Each character inS
is a type of stone you have. You want to know how many of the stones you have are also jewels.
The letters in
J
are guaranteed distinct, and all characters inJ
andS
are letters. Letters are case sensitive, so"a"
is considered a different type of stone from"A"
.
Note:
S
andJ
will consist of letters and have length at most 50.- The characters in
J
are distinct.
你有一段字串
J
代表有哪些石頭的種類是珠寶,還有一段字串S
代表你有哪些石頭。每一個在S
裡面的字元是代表你有的石頭的種類。你想要知道你有的石頭之中有多少珠寶。
這些在
J
裡面的字母都不相同,並且在J
和S
裡面的字元一定是字母。字母的大小寫是需要在意的,所以a
和A
被視為是不同種類的石頭。
注意:
S
和J
只包含字母且長度不超過50。J
裡面的字元都不相同。
J
裡面出現的字。S
的字是否出現在hash裡面。LeetCode
C++