Grokking Data Structures & Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Problem 2: Jewels and Stones (easy)
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Problem Statement

Given two strings. The first string represents types of jewels, where each character is a unique type of jewel. The second string represents stones you have, where each character represents a type of stone. Determine how many of the stones you have are also jewels.

Examples:

  1. Example 1:

    • Input: Jewels = "abc", Stones = "aabbcc"
    • Expected Output: 6
    • Justification: All the stones are jewels.
  2. Example 2:

    • Input: Jewels = "aA", Stones = "aAaZz"
    • Expected Output: 3
    • Justification: There are 2 'a' and 1 'A' stones that are jewels.

3

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible