Tap here to switch tabs
Problem
Ask
Submissions

Problem: Jewels and Stones

easy
15 min
Explore how to identify and count characters in stones that match jewel types using hash maps. This lesson helps you understand case-sensitive character comparison and apply hash maps for efficient coding interview solutions.

Statement

You are given two strings, jewels and stones. Each character in jewels represents a stone type that is a jewel, and each character in stones represents a stone you have. Count how many characters in stones belong to the set of characters in jewels.

Note: Matching is case-sensitive, so 'a' and 'A' are different types of stones.

Constraints:

  • 11 \leq jewels.length, stones.length 50 \leq 50

  • jewels and stones consist of only English letters.

  • All the characters of jewels are unique.

Tap here to switch tabs
Problem
Ask
Submissions

Problem: Jewels and Stones

easy
15 min
Explore how to identify and count characters in stones that match jewel types using hash maps. This lesson helps you understand case-sensitive character comparison and apply hash maps for efficient coding interview solutions.

Statement

You are given two strings, jewels and stones. Each character in jewels represents a stone type that is a jewel, and each character in stones represents a stone you have. Count how many characters in stones belong to the set of characters in jewels.

Note: Matching is case-sensitive, so 'a' and 'A' are different types of stones.

Constraints:

  • 11 \leq jewels.length, stones.length 50 \leq 50

  • jewels and stones consist of only English letters.

  • All the characters of jewels are unique.