Amazon Coding Interview (2019) - Jewels and Stones (LeetCode)
Jewels and Stones LeetCode coding solution. One of Amazon's most commonly asked interview questions according to LeetCode.
Coding InterviewsJewels and Stones (LeetCode) question and explanation.
This question is a commonly asked by the following companies:, Amazon, Adobe, and Alibaba.
Link to problem: https://leetcode.com/problems/jewels-and-stones/description/
Problem description: You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels.
The letters in J are guaranteed distinct, and all characters in J and S are letters. Letters are case sensitive, so "a" is considered a different type of stone from "A".
Example 1:
Input: J = "aA", S = "aAAbbbb"
Output: 3
Example 2:
Input: J = "z", S = "ZZ"
Output: 0
Note:
S and J will consist of letters and have length at most 50.
The characters in J are distinct.
Intuition behind solution: Iterate through each character in J placing it in a hash set to represent the jewels. Then iterate through each character in S, asking if the current character exists in the jewels hash set. If it does, increment a count. Once the loop terminates, simply return the count.
Support me on Patreon: https://www.patreon.com/KevinNaughtonJr
Follow me on Twitter: https://twitter.com/KevinNaughtonJr
Follow me on Instagram: https://www.instagram.com/programeme
Follow me on GitHub: https://github.com/kdn251
Видео Amazon Coding Interview (2019) - Jewels and Stones (LeetCode) канала Kevin Naughton Jr.
Coding InterviewsJewels and Stones (LeetCode) question and explanation.
This question is a commonly asked by the following companies:, Amazon, Adobe, and Alibaba.
Link to problem: https://leetcode.com/problems/jewels-and-stones/description/
Problem description: You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels.
The letters in J are guaranteed distinct, and all characters in J and S are letters. Letters are case sensitive, so "a" is considered a different type of stone from "A".
Example 1:
Input: J = "aA", S = "aAAbbbb"
Output: 3
Example 2:
Input: J = "z", S = "ZZ"
Output: 0
Note:
S and J will consist of letters and have length at most 50.
The characters in J are distinct.
Intuition behind solution: Iterate through each character in J placing it in a hash set to represent the jewels. Then iterate through each character in S, asking if the current character exists in the jewels hash set. If it does, increment a count. Once the loop terminates, simply return the count.
Support me on Patreon: https://www.patreon.com/KevinNaughtonJr
Follow me on Twitter: https://twitter.com/KevinNaughtonJr
Follow me on Instagram: https://www.instagram.com/programeme
Follow me on GitHub: https://github.com/kdn251
Видео Amazon Coding Interview (2019) - Jewels and Stones (LeetCode) канала Kevin Naughton Jr.
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![Google Coding Interview (2019) - Sort Characters By Frequency (LeetCode)](https://i.ytimg.com/vi/trFw8IDw2Vg/default.jpg)
![LeetCode 317 Shortest Distance from All Buildings](https://i.ytimg.com/vi/8K98WexA8m8/default.jpg)
![Learn Javascript Programming #4: For Loops (Looping Through Numbers, Arrays, Objects)](https://i.ytimg.com/vi/BxFi7vVZx4s/default.jpg)
![Amazon Coding Interview (2019) - Lowest Common Ancestor of a Binary Search Tree (LeetCode)](https://i.ytimg.com/vi/kulWKd3BUcI/default.jpg)
![Facebook Coding Interview (2019) - Add Binary (LeetCode)](https://i.ytimg.com/vi/tRpusgdZxrE/default.jpg)
![Can You Solve Amazon's Hanging Cable Interview Question?](https://i.ytimg.com/vi/l_ffdarcJiQ/default.jpg)
![Python: Hashmap using Lists](https://i.ytimg.com/vi/9HFbhPscPU0/default.jpg)
![Amazon Coding Interview (2019) - Symmetric Tree (LeetCode)](https://i.ytimg.com/vi/K7LyJTWr2yA/default.jpg)
![Google Coding Interview (2019) - Letter Combinations of a Phone Number (LeetCode)](https://i.ytimg.com/vi/21OuwqIC56E/default.jpg)
![Facebook Coding Interview (2019) - Monotonic Array (LeetCode)](https://i.ytimg.com/vi/wqgvE8X-2jk/default.jpg)
![10 Jewelry Terms You Need to Know - Jewelry Terminology for Beginners](https://i.ytimg.com/vi/RAaxMRkPEHQ/default.jpg)
![Product of Array Except Self (Leetcode #238)](https://i.ytimg.com/vi/61IjpElFcn8/default.jpg)
![Amazon Coding Interview: Count Negative Integers in Row/Column-Wise Sorted Matrix](https://i.ytimg.com/vi/5dJSZLmDsxk/default.jpg)
![Amazon Coding Interview (2019) - K Closest Points to Origin (LeetCode)](https://i.ytimg.com/vi/1rEUgAG7f_c/default.jpg)
![Amazon Coding Interview (2019) - Missing Number (LeetCode)](https://i.ytimg.com/vi/YMYVYSWL93w/default.jpg)
![Amazon Coding Interview (2019) - Unique Paths (LeetCode)](https://i.ytimg.com/vi/6qMFjFC9YSc/default.jpg)
![How to Succeed in any Programming Interview 2018](https://i.ytimg.com/vi/5KB5KAak6tM/default.jpg)
![【LeetCode习题讲解】 771. Jewels and stones](https://i.ytimg.com/vi/pAksnBroOHc/default.jpg)
![Amazon Coding Interview (2019) - Most Common Word (LeetCode)](https://i.ytimg.com/vi/q2v5nik5vwU/default.jpg)