Class Solution

java.lang.Object
g0701_0800.s0771_jewels_and_stones.Solution

public class Solution extends Object
771 - Jewels and Stones.<p>Easy</p> <p>You&rsquo;re given strings <code>jewels</code> representing the types of stones that are jewels, and <code>stones</code> representing the stones you have. Each character in <code>stones</code> is a type of stone you have. You want to know how many of the stones you have are also jewels.</p> <p>Letters are case sensitive, so <code>&quot;a&quot;</code> is considered a different type of stone from <code>&quot;A&quot;</code>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> jewels = &ldquo;aA&rdquo;, stones = &ldquo;aAAbbbb&rdquo;</p> <p><strong>Output:</strong> 3</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> jewels = &ldquo;z&rdquo;, stones = &ldquo;ZZ&rdquo;</p> <p><strong>Output:</strong> 0</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= jewels.length, stones.length <= 50</code></li> <li><code>jewels</code> and <code>stones</code> consist of only English letters.</li> <li>All the characters of <code>jewels</code> are <strong>unique</strong>.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • numJewelsInStones

      public int numJewelsInStones(String jewels, String stones)