DEV Community

Rohan Ravindra Kadam
Rohan Ravindra Kadam

Posted on

LeetCode : Jewels and Stones With Solutions

Hey🖐 DevCommunity Checkout The blog for solutions above Leetcode problem statement

Problem Statement

You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the stones you have are also jewels.

Letters are case sensitive, so "a" is considered a different type of stone from "A".

Example 1:

Input: jewels = "aA", stones = "aAAbbbb"
Output: 3
Enter fullscreen mode Exit fullscreen mode

Example 2:

Input: jewels = "z", stones = "ZZ"
Output: 0
Enter fullscreen mode Exit fullscreen mode


  • 1 <= jewels.length, stones.length <= 50
  • jewels and stones consist of only English letters.
  • All the characters of jewels are unique.


class Solution {
    public int numJewelsInStones(String jewels, String stones) {
         int count= 0;
        for (char jewel:jewels.toCharArray()) {
            for (char stone:stones.toCharArray()) {

        return count;
Enter fullscreen mode Exit fullscreen mode


In this article, we learned way to solve LeetCode Problem Statement Jewels and Stones using java.

Checkout More about Me by visiting on below links

Github:- Rohan2596
Instagram:- rohankadam_codes

Thank You For Reading.Do like ❤ Share and Follow for more content like this.
Also share feedbacks and Solution in the comment section below

Top comments (0)