Count Case-Sensitive Jewel Occurrences

Quick Overview

Count Case-Sensitive Jewel Occurrences. jewels lists distinct character types that count as jewels. stones lists individual stones by character.

Count Case-Sensitive Jewel Occurrences

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Other

### Problem jewels lists distinct character types that count as jewels. stones lists individual stones by character. Return how many stone occurrences have a type in jewels, treating uppercase and lowercase as different types. ```cpp class Solution { public: int numJewelsInStones(string jewels, string stones); }; ``` ### Examples **Example 1:** ```text jewels = "bC", stones = "bbCcB" Output: 3 Explanation: Two b occurrences and one C qualify. ``` **Example 2:** ```text jewels = "Q", stones = "qqQ" Output: 1 Explanation: Only the uppercase Q matches. ``` ### Constraints - Both strings have lengths from 1 through 50. - They contain English letters only. - Characters in jewels do not repeat. ### Contract considerations Preserve case sensitivity. ```hint Read the boundary condition Can each stone contribute a simple membership indicator? ``` ### Boundary reminders Preserve case sensitivity.

Overview: Count Case-Sensitive Jewel Occurrences. jewels lists distinct character types that count as jewels. stones lists individual stones by character.

Amazon logo
Amazon
Source window: 0–3 months · as of Oct 21, 2026
easySoftware EngineerOtherCoding & Algorithms
0
0

Problem

jewels lists distinct character types that count as jewels. stones lists individual stones by character. Return how many stone occurrences have a type in jewels, treating uppercase and lowercase as different types.

class Solution {
public:
    int numJewelsInStones(string jewels, string stones);
};

Examples

Example 1:

jewels = "bC", stones = "bbCcB"
Output: 3
Explanation: Two b occurrences and one C qualify.

Example 2:

jewels = "Q", stones = "qqQ"
Output: 1
Explanation: Only the uppercase Q matches.

Constraints

  • Both strings have lengths from 1 through 50.
  • They contain English letters only.
  • Characters in jewels do not repeat.

Contract considerations

Preserve case sensitivity.

Boundary reminders

Preserve case sensitivity.