• Skip to primary navigation
  • Skip to content
  • Skip to footer
Dev Battery Dev Battery Keep your battery charged
    Wonjun Jeong

    Wonjun Jeong

    Backend Developer

    • Korea Republic
    • Email
    • GitHub
  • All Posts (833)
    • ๐Ÿ“ˆ Algorithm
      • Recap (4)
      • LeetCode (116)
      • HackerRank (130)
      • Codeforces (43)
      • Programmers (88)
      • Baekjoon (153)
      • Inflearn (2)
    • ๐Ÿ“’ Issue
      • Project (23)
    • ๐Ÿง‘๐Ÿปโ€๐Ÿ’ป Programming
      • DevOps (3)
      • Java (15)
      • Spring (21)
      • FastAPI (0)
      • Vue (1)
      • React (1)
    • ๐Ÿ–ฅ๏ธ Computer Science
      • Network (7)
      • Database (10)
      • Data Structure (13)
    • ๐Ÿ€ CodeSquad
      • Today I Learned (197)

    [LeetCode] 771. Jewels and Stones (Python)

    Published: 2023-06-10
    Updated: 2023-06-10

    On this page

    • Solution
    • Reference


    Solution

    class Solution:
        def numJewelsInStones(self, jewels: str, stones: str) -> int:
            answer = 0
            jewels_map = {}
    
            for jewel in jewels:
                jewels_map[jewel] = 1
    
            for stone in stones:
                if stone in jewels_map:
                    answer += 1
    
            return answer
    

    Tags: hash-table, python, string

    Categories: LeetCode

    Published: 2023-06-10
    Updated: 2023-06-10

    Previous Next

    Leave a comment

    You may also enjoy

    [Devops] AWS์˜ Auto Scaling์œผ๋กœ Scale-out ํ•˜์—ฌ ์„œ๋ฒ„ ๋ถ„์‚ฐํ•˜์—ฌ ๋ฐฐํฌ

    Published: 2025-08-25
    Updated: 2025-08-31

    devops, aws, auto-scaling, serverless

    [Devops] ๋งฅ๋ถ(MacOS)์„ EC2 ์„œ๋ฒ„์ฒ˜๋Ÿผ ์จ๋ณด์ž! - Cloudflare, DNS

    Published: 2025-06-24
    Updated: 2025-06-24

    devops, cloudflare

    [Project] Vite React ํ™˜๊ฒฝ์—์„œ ์ด๋ฏธ์ง€ ์ปดํฌ๋„ŒํŠธ ๋กœ๋”ฉ ์ตœ์ ํ™” ๋ฐฉ๋ฒ•

    Published: 2025-05-09
    Updated: 2025-05-12

    movlit, vite, react, image, loading

    [React] Node.js์™€ npm ์„ค์น˜ ํ›„ Vite React ๊ฐœ๋ฐœ ์„œ๋ฒ„ ์‹คํ–‰ ๋ฐฉ๋ฒ•

    Published: 2025-05-08
    Updated: 2025-05-08

    react, vite, node, npm